public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3638] c++: constexpr error with defaulted virtual dtor [PR93413] Date: Thu, 3 Nov 2022 18:56:32 +0000 (GMT) [thread overview] Message-ID: <20221103185632.253683858428@sourceware.org> (raw) https://gcc.gnu.org/g:c0b38e9fec71dc4cc5e99b1f0cb159c15a8da9ba commit r13-3638-gc0b38e9fec71dc4cc5e99b1f0cb159c15a8da9ba Author: Patrick Palka <ppalka@redhat.com> Date: Thu Nov 3 14:55:35 2022 -0400 c++: constexpr error with defaulted virtual dtor [PR93413] We're rejecting the below testcase with error: 'virtual constexpr Base::~Base()' used before its definition error: 'virtual constexpr Derived::~Derived()' used before its definition due to special handling in mark_used added by r181272 to defer synthesis of virtual destructors until EOF (where we can set their linkage), which in turn makes them effectively unusable during constexpr evaluation. Fortunately it seems this special handling is unnecessary ever since r208030 enabled us to tentatively set linkage of all defaulted virtual destructors, including templated ones. So this patch gets rid of this special handling. PR c++/93413 gcc/cp/ChangeLog: * decl2.cc (mark_used): Don't defer synthesis of virtual functions. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-virtual21.C: New test. Diff: --- gcc/cp/decl2.cc | 8 -------- gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index e6779268ad4..eeb59eae64f 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -5788,14 +5788,6 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) && !DECL_DEFAULTED_OUTSIDE_CLASS_P (decl) && ! DECL_INITIAL (decl)) { - /* Defer virtual destructors so that thunks get the right - linkage. */ - if (DECL_VIRTUAL_P (decl) && !at_eof) - { - note_vague_linkage_fn (decl); - return true; - } - /* Remember the current location for a function we will end up synthesizing. Then we can inform the user where it was required in the case of error. */ diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C new file mode 100644 index 00000000000..8b70c5f538b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C @@ -0,0 +1,10 @@ +// PR c++/93413 +// { dg-do compile { target c++20 } } + +struct Base { + virtual ~Base() = default; +}; +constexpr Base b; + +struct Derived : Base { }; +constexpr Derived d;
reply other threads:[~2022-11-03 18:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221103185632.253683858428@sourceware.org \ --to=ppalka@gcc.gnu.org \ --cc=gcc-cvs@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).