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

            Bug ID: 115985
           Summary: anoymous struct with base class rejected by gcc
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

The following code is rejected by GCC but accepted by other compilers including
clang, MSVC and EDG:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct empty{

};

struct outer{ 
    struct : public empty{ int x; }; 
};

int main(){
    int res=outer().x;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C++ standard says little about anonymous struct, so I'm unsure which side is
correct.

https://godbolt.org/z/4aKfKvdzb

Note that the code can be accepted if the unnamed struct has an instantiation: 

https://godbolt.org/z/M8q3raWW8

Reply via email to