Issue 143689
Summary Uninitialized `constinit struct S` is rejected
Labels new issue
Assignees
Reporter Eisenwave
    https://godbolt.org/z/b4E6zYGPG
```cpp
struct S { int x; };
constinit S x;
```
Clang rejects this, GCC accepts. I believe Clang is wrong:
```
<source>:3:13: error: variable does not have a constant initializer
    3 | constinit S x;
      | ^
<source>:3:1: note: required by 'constinit' specifier here
    3 | constinit S x;
      | ^~~~~~~~~
<source>:3:13: note: subobject 'x' is not initialized
    3 | constinit S x;
      |             ^
<source>:1:16: note: subobject declared here
    1 | struct S { int x; };
 |
```
https://eel.is/c++draft/dcl.constinit specifies that the program is ill-formed if `x` has dynamic initialization.

There is obviously no dynamic initialization happening here, so this error makes no sense.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to