From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A35F0387093E; Tue, 14 May 2024 09:38:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A35F0387093E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715679483; bh=ohQHCUikXaFTCsCCft4H2INtmKg/YhzoRnXkd0tbKbs=; h=From:To:Subject:Date:From; b=tJtC6WYxb4IyJCoWgwlmjSk3mnD2PcKfHgtmpIBe4QESwSbPet1q1V/69U/nCjp6f 1kJcbnHSwsl5mGRShj5WDPibxJQIVJrPvrNWpgCHiiAo6yF7L7Z1cI6Li7yP8VURxi QQe3TSrOQK7VfHvUslU4VfFwu60T5/BJvmOUGpm4= From: "janschultke at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/115085] New: Variable unqualified-id is falsely treated as rvalue when appearing in braced-init-list Date: Tue, 14 May 2024 09:38:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: janschultke at googlemail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115085 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 =3D decltype((a)){a}; GCC falsely rejects this (https://godbolt.org/z/a6c4h8Mhv). If you're having trouble reading this, it also rejects: > using T =3D int&; > int a{}, b =3D T{a}; Splitting this into multiple lines is also not relevant. The error is: > :3:17: error: cannot bind non-const lvalue reference of type 'T' = {aka 'int&'} to an rvalue of type 'int' > 3 | int a{}, b =3D 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.=