From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C43953858D35; Fri, 5 Nov 2021 06:29:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C43953858D35 From: "josephcsible at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103091] New: Can't jump into scope of a variable with a nontrivial destructor in C++20 Date: Fri, 05 Nov 2021 06:29:55 +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.2.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: josephcsible 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 keywords 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: Fri, 05 Nov 2021 06:29:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103091 Bug ID: 103091 Summary: Can't jump into scope of a variable with a nontrivial destructor in C++20 Product: gcc Version: 11.2.1 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: josephcsible at gmail dot com Target Milestone: --- The C++17 standard says "A program that jumps from a point where a variable with automatic storage duration is not in scope to a point where it is in s= cope is ill-formed unless the variable has scalar type, class type with a trivial default constructor and a trivial destructor, a cv-qualified version of one= of these types, or an array of one of the preceding types and is declared with= out an initializer (11.6)." The C++20 standard says "A program that jumps from a point where a variable with automatic storage duration is not in scope to a point where it is in s= cope is ill-formed unless the variable has vacuous initialization (6.7.3)." and = "A variable is said to have vacuous initialization if it is default-initialized and, if it is of class type or a (possibly multi-dimensional) array thereof, that class type has a trivial default constructor." Note that the C++17 standard mentions a trivial destructor here, but the C+= +20 standard does not. Now consider this code: struct MyStruct { ~MyStruct() {} }; void foo() { goto x; MyStruct s; x: return; } It's ill-formed in C++17, but fine in C++20. However, we currently reject t= his program even with -std=3Dc++20.=