Bug 1569374 - Regression error: constructor required before non-static data member
Summary: Regression error: constructor required before non-static data member
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc
Version: DTS 7.0 RHEL 7
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: alpha
: 7.1
Assignee: Marek Polacek
QA Contact: Michael Petlan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-19 07:37 UTC by Jiangdong Sun
Modified: 2018-11-13 08:39 UTC (History)
7 users (show)

Fixed In Version: devtoolset-8-gcc-8.1.1-5.el7
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2018-11-13 08:38:30 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3562 0 None None None 2018-11-13 08:39:11 UTC

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


Note You need to log in before you can comment on or make changes to this bug.