From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 753693898524; Thu, 30 Apr 2020 20:48:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 753693898524 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588279687; bh=dEyttl3BnBsTquvdyprjsKXJJrhgDFCGMejFnZPzSvA=; h=From:To:Subject:Date:From; b=lbt7wx7MueEn9MhTzBW2WvOrTnfGdubWUDwx7WPZixG2lAsbp9GiPTe8TuFjEBPb6 8QJg6CEDNg3I6WUGYhvM9jnVJjqD1SphAlHJPwJ66YWRRwDDBhV0BHdZw/ni9kSAcW y+04diVW4tNHS2OuWxd5JhTtw/O6xQzal8rQhGxA= From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94897] New: range-for produces a variable initialiser with use of a forward decl. Date: Thu, 30 Apr 2020 20:48:07 +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: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2020 20:48:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94897 Bug ID: 94897 Summary: range-for produces a variable initialiser with use of a forward decl. Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iains at gcc dot gnu.org Target Milestone: --- It seems that parser.c:cp_convert_range_for () is not implementing the lowe= ring that its header comment outlines. for this: #include void foo () { const std::array expectedValues =3D {{0, 3, 1, 4, 2}}; for (int expectedValue : expectedValues) { ; } } we are getting the statement tree below, the key being (V =3D Var decl, Va = =3D artificial var decl) where the first entry initialiser contains a forward r= ef. ---- V int expectedValue =3D E (std::array5>::value_type)E *VD foo::__for_begin; Va const std::array5>& __for_range =3D E (const std::array5>&)E &foo::expectedValues; Va const std::array5>::value_type* __for_begin; Va const std::array5>::value_type* __for_end; =3D=3D=3D=3D=3D FD foo ()=20 - { S BIND_EXPR [scope 0x10399a3c0] BLOCK #0 not outer [ao] 0x0=20 [super-ctx] 0x0 SUBBLOCKS 0x10399a360 VARS { V const std::array5>expectedValues =3D {E CE {E 0, E 3, E 1, E 4, E 2}}; } BODY { - { CPs<5>expectedValues =3D {E CE {E 0, E 3, E 1, E 4, E 2}}; CPE>> S BIND_EXPR [scope 0x10399a360] BLOCK #0 not outer [ao] 0x0=20 [super-ctx] 0x10399a3c0 SUBBLOCKS 0x0 VARS { V int expectedValue =3D E (std::array5>::value_type)E = *VD foo::__for_begin; Va const std::array5>& __for_range =3D E (const std::array5>&)E &foo::expectedValues; Va const std::array5>::value_type* __for_begin; Va const std::array5>::value_type* __for_end; } BODY { - { sD const std::array5>& __for_range =3D E (const std::array5>&)E &foo::expectedValues; sD const std::array5>::value_type* __for_begin; CPs<5>::begin (); CPE>> sD const std::array5>::value_type* __for_end; CPs<5>::end (); CPE>> sS for (; E CE foo::__for_begin !=3D foo::__for_end; CPe<>) sD int expectedValue =3D E (std::array5>::value_t= ype)E *VD foo::__for_begin; } } } }=