From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6D335383E826; Mon, 13 Jul 2020 12:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D335383E826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594644084; bh=hzGFxvuF5I24s82dazRfxTyQXp1ZUXRl2ncdZVK4PQg=; h=From:To:Subject:Date:From; b=CGm2X20Wct4R0GzxH9Ovflc9FgLHljvSkelONWwe4JskBo3McslIB22kXu7mMWgJr ZycK7S7uL4l1V3/rVkVeVcOdpEQIBbPRPS26fXcxmvukxMbxuZeOsAAftz5nUNvyFA s2mfkSnhofJI3pLp7qusGCsqfnMWpHIX6PAOFzW0= From: "haoxintu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96184] New: GCC treats "use of local variable with automatic storage from containing function" differently in versions Date: Mon, 13 Jul 2020 12:41:24 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: haoxintu at gmail 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 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: Mon, 13 Jul 2020 12:41:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96184 Bug ID: 96184 Summary: GCC treats "use of local variable with automatic storage from containing function" differently in versions Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi, all. This code, GCC-trunk and other versions (etc., GCC-10) treat it differently. $cat test.cc int main(){ int a =3D 10; int const b =3D 10; auto p =3D [ ] () noexcept ( b ? 0 : a =3D b) { return 0;}; return 0; } $g++-trunk -std=3Dc++14 test.cc //nothing $g++-10 -std=3Dc++14 test.cc test.cc: In function =E2=80=98int main()=E2=80=99: test.cc:4:40: error: use of local variable with automatic storage from containing function 4 | auto p =3D [ ] () noexcept ( b ? 0 : a =3D b) { return 0;}; | ^ test.cc:2:9: note: =E2=80=98int a=E2=80=99 declared here 2 | int a =3D 10; | ^ I am wondering is this a enhancement of GCC-trunk?=20 I also test this in other GCC versions. Weirdly, only GCC-9 or GCC-10 rejec= ts it while other versions from 6.1 to 8.3 (also trunk) accepts it. I don't know how GCC deals with this case and this also makes me confused. Thanks, Haoxin=