https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124300
Bug ID: 124300
Summary: Accepts invalid constexpr on anonymous union
declaration
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: suyuchang at whu dot edu.cn
Target Milestone: ---
The code applies constexpr to an anonymous union declaration. Clang rejects the
code. GCC accepts it.
Code:
union { } constexpr;
Command:
clang++ test.cpp
<source>:1:11: error: union cannot be marked constexpr
1 | union { } constexpr;
| ^
1 error generated.
See Compiler Explorer: https://godbolt.org/z/sfM8Tanc7
The test case was generated by a fuzzer.