https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97363
Bug ID: 97363 Summary: Missing diagnostics when trying to initialize rvalue reference variable with lvalue expression when using decltype(auto) type deduction. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: anders.granlund.0 at gmail dot com Target Milestone: --- Consider the following program: int main() { int &&x = 0; decltype(auto) y = x; // Should behave like int &&y = x; and thus give a // compilation error since x is an lvalue. } When compiling it with -std=c++20 -pedantic-errors it compiles without errors. I expect it instead to give a compilation error for the reason given in the comment in the program. Note that clang correctly gives the expected compilation error. Compiler explorer link (clang to the left and gcc to the right): https://godbolt.org/z/xzfjMP