public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "oleksandr.koval.dev at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99495] New: constexpr virtual destructor is used before its definition Date: Tue, 09 Mar 2021 19:14:25 +0000 [thread overview] Message-ID: <bug-99495-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99495 Bug ID: 99495 Summary: constexpr virtual destructor is used before its definition Product: gcc Version: 11.0 URL: https://godbolt.org/z/GGY6aa Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: oleksandr.koval.dev at gmail dot com Target Milestone: --- I found this while playing with constexpr virtual functions. This code gives "error: 'virtual constexpr Derived2::~Derived2()' used before its definition". Error always refers to the last variable, e.g. if we swap d1 and d2 declarations, it will complain about d1. If x is decalred without constexpr it works fine. struct Base{ constexpr virtual ~Base() = default; virtual int Get() const = 0; // non-constexpr }; struct Derived1 : Base{ constexpr int Get() const override { return 1; } }; struct Derived2 : Base{ constexpr int Get() const override { return 2; } }; constexpr auto GetSum(){ const Derived1 d1; const Derived2 d2; const Base* pb1 = &d1; const Base* pb2 = &d2; return pb1->Get() + pb2->Get(); } constexpr // error int x = GetSum(); // OK if not in constexpr context
next reply other threads:[~2021-03-09 19:14 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-09 19:14 oleksandr.koval.dev at gmail dot com [this message] 2021-04-24 2:38 ` [Bug c++/99495] " pdimov at gmail dot com 2021-08-17 5:57 ` pinskia 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-99495-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).