public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114388] New: Behavioral change of typeid on xvalues since GCC 9 Date: Tue, 19 Mar 2024 06:27:36 +0000 [thread overview] Message-ID: <bug-114388-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114388 Bug ID: 114388 Summary: Behavioral change of typeid on xvalues since GCC 9 Product: gcc Version: 9.5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- IIUC this program behaves differently in C++98 and C++11 due to WG21 N3055 (https://wg21.link/n3055): ``` #include <typeinfo> #include <cstdio> struct B { virtual ~B() { std::puts("~B"); } }; struct D : B {}; struct WrapB { B b; }; struct WrapD { D d; }; int main() { typeid(true ? WrapB().b : WrapD().d); } ``` Before C++11/N3055, the operand of the typeid expression shouldn't be evaluated because it's a rvalue. But since C++11 it should be evaluated because it's a glvalue of a polymorphic class type. It's curious that GCC behaves consistently on this in C++98 and C++11 modes. Per https://godbolt.org/z/7oGdjdMK7, it seems that GCC 8 (and former versions) applied the C++98 rules to C++11 and later modes, and GCC 9 (and later verions) applied the C++11 rules to C++98 mode. For later versions, I'm not sure whether this is a bug (in C++98 mode) or an intentional backporting.
next reply other threads:[~2024-03-19 6:27 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-19 6:27 de34 at live dot cn [this message] 2024-03-19 6:34 ` [Bug c++/114388] " de34 at live dot cn 2024-03-19 8:00 ` rguenth at gcc dot gnu.org 2024-03-19 8:21 ` de34 at live dot cn 2024-03-19 10:54 ` redi at gcc dot gnu.org 2024-03-19 11:12 ` redi at gcc dot gnu.org 2024-03-19 11:31 ` redi at gcc dot gnu.org 2024-03-19 11:43 ` de34 at live dot cn 2024-03-19 11:51 ` redi at gcc dot gnu.org 2024-03-19 11:54 ` redi at gcc dot gnu.org 2024-04-30 6:53 ` de34 at live dot cn
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-114388-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).