Bug 1569374

Summary: Regression error: constructor required before non-static data member
Product: Red Hat Developer Toolset Reporter: Jiangdong Sun <sunjdong>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: high Docs Contact:
Priority: unspecified    
Version: DTS 7.0 RHEL 7CC: jakub, kanderso, law, mcermak, mnewsome, mpetlan, ohudlick
Target Milestone: alpha   
Target Release: 7.1   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-8-gcc-8.1.1-5.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-13 08:38:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jiangdong Sun 2018-04-19 07:37:36 UTC
Description of problem:
Looks it's the same problem as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70528. It happens with devtoolset-7-gcc-c++-7.2.1-1

How reproducible:
The code ( extacted from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70528 )

template <class T, class U = decltype(T())>                                                                                         
struct I {                                                                                                                          
};                                                                                                                                  
                                                                                                                                    
struct J {                                                                                                                          
  struct K {                                                                                                                        
    int First = 0;                                                                                                                  
  };                                                                                                                                
  I<K> FunctionMDInfo;                                                                                                              
};  

Steps to Reproduce:
1. when compiles the above code snippet with "g++ (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)" from gcc-c++-4.8.3-9.el7.x86_64, the compiling passes.

2. when compiles the above code snippet with "g++ (GCC) 7.2.1 20170829 (Red Hat 7.2.1-1)" from devtoolset-7-gcc-c++-7.2.1-1 . It shows the following error messages.

t.cpp:1:39: error: constructor required before non-static data member for ‘J::K::First’ has been parsed
 template <class T, class U = decltype(T())>
                                       ^~~

Comment 2 Jiangdong Sun 2018-04-19 08:53:36 UTC
Additionally, when compiling the code snippet with g++ 4.8.3, need to add the option "std=c++11"

Comment 3 Marek Polacek 2018-04-19 16:33:02 UTC
Isn't that invalid though?  I mean, trunk g++ rejects the code:

70528.C:1:39: error: default member initializer for ‘J::K::First’ required before the end of its enclosing class
 template <class T, class U = decltype(T())>
                                       ^~~
70528.C:7:15: note: defined here
     int First = 0;
               ^~~~

as does clang++:

70528.C:1:39: error: default member initializer for 'First' needed within definition of enclosing class
      'J' outside of member functions
template <class T, class U = decltype(T())>
                                      ^
70528.C:9:3: note: in instantiation of default argument for 'I<J::K>' required here
  I<K> FunctionMDInfo;
  ^~~~
70528.C:7:9: note: default member initializer declared here
    int First = 0;
        ^
1 error generated.

Comment 4 Marek Polacek 2018-07-13 17:56:36 UTC
The PR has been resolved and the code is rejected (as it should be).  Let's move on with this one.

Comment 6 Michael Petlan 2018-11-09 00:38:58 UTC
VERIFIED for devtoolset-8-gcc-8.2.1-3. The related tests passed.

Comment 8 errata-xmlrpc 2018-11-13 08:38:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3562