https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115085
Bug ID: 115085 Summary: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- > int a{}, b = decltype((a)){a}; GCC falsely rejects this (https://godbolt.org/z/a6c4h8Mhv). If you're having trouble reading this, it also rejects: > using T = int&; > int a{}, b = T{a}; Splitting this into multiple lines is also not relevant. The error is: > <source>:3:17: error: cannot bind non-const lvalue reference of type 'T' {aka > 'int&'} to an rvalue of type 'int' > 3 | int a{}, b = T{a}; > | ^ There is no apparent reason why should be an rvalue in this context. It is not move-eligible within the initializer of a variable. My guess is something something aggregate initialization doing copy-initialization for each initializer and then getting a prvalue out of that. Dunno, it's quite weird. See https://stackoverflow.com/a/78477064/5740428 for a more in-depth explanation of the relevant wording.