public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "officesamurai at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95638] New: Legit-looking code doesn't work with -O2 Date: Thu, 11 Jun 2020 11:45:04 +0000 [thread overview] Message-ID: <bug-95638-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95638 Bug ID: 95638 Summary: Legit-looking code doesn't work with -O2 Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: officesamurai at gmail dot com Target Milestone: --- Created attachment 48718 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48718&action=edit The failing code The attached code produces wrong result when build with -O2 and without -fno-strict-aliasing, but I don't believe it does anything illegal. The only fishy thing it does is creating a pointer to T before an object of that type is constructed at that location (in Storage::Storage and Storage::push_back), but the pointer is just passed to the placement new, which should be fine according to [basic.life] (because "...using the pointer as if the pointer were of type void*, is well-defined"). ------------------------ $ g++-10.1.0 -v Using built-in specs. COLLECT_GCC=g++-10.1.0 COLLECT_LTO_WRAPPER=/home/brd/soft/gcc-10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ./configure --prefix=/home/brd/soft/gcc-10.1.0 Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.1.0 (GCC) $ g++-10.1.0 -O2 gcc10_aliasing_issue.cpp -o test -std=c++14 && ./test Null!!! $ g++-10.1.0 -O2 -fno-strict-aliasing gcc10_aliasing_issue.cpp -o test -std=c++14 && ./test OK ------------------------ P.S. The same code works fine with GCC 9 and earlier versions.
next reply other threads:[~2020-06-11 11:45 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-11 11:45 officesamurai at gmail dot com [this message] 2020-06-11 12:08 ` [Bug c++/95638] " jakub at gcc dot gnu.org 2020-06-11 12:12 ` marxin at gcc dot gnu.org 2020-06-11 12:23 ` jakub at gcc dot gnu.org 2020-06-11 15:40 ` redi at gcc dot gnu.org 2020-06-12 1:17 ` amker at gcc dot gnu.org 2020-06-12 7:20 ` [Bug c++/95638] [10/11 Regression] " rguenth at gcc dot gnu.org 2020-06-14 0:47 ` amker at gcc dot gnu.org 2020-06-20 7:56 ` [Bug tree-optimization/95638] " cvs-commit at gcc dot gnu.org 2020-06-29 10:07 ` jakub at gcc dot gnu.org 2020-06-29 12:10 ` amker at gcc dot gnu.org 2020-07-09 11:47 ` rguenth at gcc dot gnu.org 2020-07-09 11:48 ` [Bug tree-optimization/95638] [10 " rguenth at gcc dot gnu.org 2020-07-10 3:59 ` cvs-commit at gcc dot gnu.org 2020-07-10 4:12 ` cvs-commit at gcc dot gnu.org 2020-07-23 6:51 ` rguenth at gcc dot gnu.org 2020-07-23 7:11 ` amker at gcc dot gnu.org 2021-03-27 2:44 ` amker 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-95638-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).