https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68085

            Bug ID: 68085
           Summary: bug when using anonymous structs in function
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.burn at gmail dot com
  Target Milestone: ---

The following code compiles fine with clang and EDG, but gives this error with
g++ -std=c++1z:

main.cpp: In function ‘auto make(int)’:
main.cpp:5:17: error: declaration of ‘int make(int)::<anonymous struct>::y’
[-fpermissive]
     decltype(y) y;
                 ^
main.cpp:3:8: error: changes meaning of ‘y’ from ‘int y’ [-fpermissive]
   auto y = x;

//////////////////////////////////////////////////////////
auto make(int x) {                                                              
  auto y = x;                                                                   
  struct {                                                                      
    decltype(y) y;                                                              
  } result{x};                                                                  
  return result;                                                                
}                                                                               

int main() {                                                                    
  return 0;                                                                     
} 
//////////////////////////////////////////////////////////

Reply via email to