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

            Bug ID: 97401
           Summary: static int has a default value?
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

Hi, the following code declares a static Integer without specific value.
Usually, it will has a default value '0', and thus 'b[a]' could be declared as
b[0] perhaps. However, gcc rejects it while clang accepts.

$ cat s.cpp
template<typename> struct A {  
  static int a;  
  char b[a]; 
};

$ g++ -c s.cpp
s.cpp:3:10: error: size of array ‘b’ is not an integral constant-expression
    3 |   char b[a];
  • [Bug c++/97401] New: stati... tangyixuan at mail dot dlut.edu.cn via Gcc-bugs

Reply via email to