[Bug c++/103347] New: Non-static data member initialization is erroneously allowed in C++03 mode

fchelnokov at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Nov 21 12:13:01 GMT 2021


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

            Bug ID: 103347
           Summary: Non-static data member initialization is erroneously
                    allowed in C++03 mode
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This code is invalid in C++03 mode:
```
#include <cstddef>
struct test {
    void *x = NULL; //invalid in C++03 mode
};
int main() {}
```
It is rejected by Clang, not not by GCC. Demo:
https://gcc.godbolt.org/z/113EWvzzx

Related discussion: https://stackoverflow.com/q/49618716/7325599


More information about the Gcc-bugs mailing list