Bug 142603 - g++ with optimization -O and above breaks at complex NaNs
g++ with optimization -O and above breaks at complex NaNs
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2004-12-10 15:50 EST by Dmitri A. Sergatskov
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version: 3.4.3-10
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-12-14 16:05:17 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dmitri A. Sergatskov 2004-12-10 15:50:36 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041111 Firefox/1.0

Description of problem:
If I compiling the following code with "-O" flag or above the
resulting code
hangs forever. Code compiled with no optimization works as expected.

#include <complex>
#include <iostream>

int main()
  std::complex<double> z1(1.0/0.0,-1.0/0.0);
  std::complex<double> z2 = std::sqrt(z1);
  std::complex<double> z3 = std::sqrt(z2);

        << "z1: " << z1 << std::endl
        << "z2: " << z2 << std::endl
        << "z3: " << z3 << std::endl;
  return 0;

Version-Release number of selected component (if applicable):
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)

How reproducible:

Steps to Reproduce:
1. Compile the code with "g++ -O"
2. Run resulting program

Actual Results:  It hangs

Expected Results:  z1: (inf,-inf)
z2: (nan,nan)
z3: (nan,nan)

Additional info:

The code works as expected with gcc version 3.2.2 20030222 (Red Hat
Linux 3.2.2-5).
Comment 2 Jakub Jelinek 2004-12-14 16:05:17 EST
Should be fixed in gcc-3.4.3-10 in rawhide.
Comment 3 Dmitri A. Sergatskov 2004-12-15 19:59:04 EST
 gcc-3.4.3-10 works for me too. Thank you for fast responce!

Note You need to log in before you can comment on or make changes to this bug.