https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124252
Bug ID: 124252
Summary: Accepts invalid cast (X0&&){} from braced-init-list
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 uses a C-style cast to an rvalue reference type with a
braced-init-list operand: (X0&&){}. Clang rejects it, but GCC accepts it.
Code:
struct X0 { } X1 = ( X0 && ) { } ;
clang++ test.cpp
<source>:1:20: error: reference to type 'X0' cannot bind to an initializer list
1 | struct X0 { } X1 = ( X0 && ) { } ;
| ^ ~~~
1 error generated.
Compiler returned: 1
g++ -c test.cpp
Compiler returned: 0
Regression since GCC 6.1
The test case was generated by a fuzzer.