public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dlong at cadence dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105071] New: Incorrect code with -Os and complex<double> Date: Sun, 27 Mar 2022 23:22:11 +0000 [thread overview] Message-ID: <bug-105071-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105071 Bug ID: 105071 Summary: Incorrect code with -Os and complex<double> Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dlong at cadence dot com Target Milestone: --- Created attachment 52691 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52691&action=edit .ii file for test case 64-bit Intel, RedHat Enterprise Linux 7.4 $ cat foo.cc #include <complex> #include <stdio.h> using namespace std; void broken(complex<double> x) { complex<double> x2=x*x; complex<double> x3=x2*x; complex<double> x4=x3*x; complex<double> x5=x4*x; complex<double> d=1.0+2.0/x+4.0/x2+8.0/x3+16.0/x4+32.0/x5; fprintf(stderr, "%e%+ej\n", real(d), imag(d)); } int main(int argc, char **argv) { broken(complex<double>(1.0, 0.000000e+00)); return 0; } $ g++-9 -Wall -o foo foo.cc && ./foo # correct 6.300000e+01+0.000000e+00j $ g++-9 -Wall -O2 -o foo foo.cc && ./foo # also correct 6.300000e+01+0.000000e+00j $ g++-9 -Wall -Os -o foo foo.cc && ./foo # wrong 1.000000e+00+0.000000e+00j If the +32.0/x5 at the end of the computation of d is omitted, then -Os also gives the correct result. $ g++-9 -v Using built-in specs. COLLECT_GCC=g++-9 COLLECT_LTO_WRAPPER=/grid/common/pkgsData/gcc-v9.3.0p3/Linux/RHEL7.0-2017-x86_64/libexec/gcc/x86_64-redhat-linux/9.3.0/lto-wrapper Target: x86_64-redhat-linux Configured with: /tmp/gcc-v9.3.0p3/gcc.source/configure --prefix=/grid/common/pkgsData/gcc-v9.3.0p3/Linux/RHEL7.0-2017-x86_64 --with-pkgversion=Cadence --disable-libgcj --enable-threads=posix --enable-shared --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --with-linker-hash-style=gnu --enable-languages=c,c++,fortran --disable-nls --enable-gnu-unique-object --enable-bootstrap --enable-plugin --enable-initfini-array --enable-linker-build-id --enable-gnu-indirect-function --enable-install-libiberty --with-ld=/grid/common/pkgsData/gcc-v9.3.0p3/Linux/RHEL7.0-2017-x86_64/bin/ld --with-as=/grid/common/pkgsData/gcc-v9.3.0p3/Linux/RHEL7.0-2017-x86_64/bin/as --build=x86_64-redhat-linux --host=x86_64-redhat-linux --with-tune=generic --enable-multiarch Thread model: posix gcc version 9.3.0 (Cadence)
next reply other threads:[~2022-03-27 23:22 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-27 23:22 dlong at cadence dot com [this message] 2022-03-27 23:29 ` [Bug middle-end/105071] [9 Regression] " pinskia at gcc dot gnu.org 2022-03-28 7:53 ` rguenth at gcc dot gnu.org 2022-03-28 11:01 ` marxin at gcc dot gnu.org 2022-03-29 16:48 ` jamborm at gcc dot gnu.org 2022-03-30 9:54 ` jamborm at gcc dot gnu.org 2022-03-30 11:51 ` cvs-commit at gcc dot gnu.org 2022-03-30 11:53 ` jamborm 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-105071-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).