https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124281
Bug ID: 124281
Summary: Rejects valid union definition in type-id with
reference qualifier
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 defines an unnamed union within a type-id and applies an rvalue
reference qualifier: using X1 = union { } &&;. Clang accepts it. GCC rejects it
with a parse error.
Code:
using X1 = union { } && ;
Command:
g++ -c test.cpp
<source>:1:21: error: expected ';' after union definition
1 | using X1 = union { } && ;
| ^
| ;
<source>:1:25: error: expected unqualified-id before ';' token
1 | using X1 = union { } && ;
| ^
See Compiler Explorer: https://godbolt.org/z/Ybcvax5xb
The test case was generated by a fuzzer.