https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100039
Bug ID: 100039
Summary: GCC can not bind lvalue to lvalue reference in
brace-initialized-temporary expression
Product: gcc
Version: 10.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
Consider this program:
typedef int& ref;
int main()
{
int a;
ref{a};
}
This is accepted by clang, msvc and icc. GCC 10.3 rejects this code with a
message:
error: cannot bind non-const lvalue reference of type 'ref' {aka 'int&'} to an
rvalue of type 'int'
I believe the error message is incorrect, because "a" is not an rvalue here. It
is lvalue, therefore it should be allowed to bind to lvalue reference.
https://godbolt.org/z/TWY9GPq3E