public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "josephcsible at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-103091-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103091 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 scope 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 without 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 scope 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 this program even with -std=c++20.
next reply other threads:[~2021-11-05 6:29 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-05 6:29 josephcsible at gmail dot com [this message] 2021-11-05 6:51 ` [Bug c++/103091] [DR 2256] " pinskia at gcc dot gnu.org 2021-11-05 6:52 ` pinskia at gcc dot gnu.org 2021-11-05 8:07 ` redi at gcc dot gnu.org 2023-05-07 16:09 ` cvs-commit at gcc dot gnu.org 2023-05-07 16:10 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103091-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).