Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Mason_W_
Beginner
57 Views

Intel 12 Floating Point Optimization -- complex<double>

I am compiling the following code with icpc 12.1.2 20111128 as on RHEL6 64-bit.

> icpc -O2 -ansi_alias -fPIC test.cc
> ./a.out
(6.95323e-310,0) (5.5, 6.6)

Both results should be (5.5, 6.6).

Here is test.cc:

#include <complex>
#include <iostream>

void badComplex(double x, double y, std::complex<double>& result)
{
  result = std::complex<double>(x,y);
}

std::complex<double> goodComplex(double x, double y)
{
  std::complex<double> result(x,y);
  return result;
}

int main()
{
  double x = 5.5;
  double y = 5.5;
  std::complex<double> badResult;
  badComplex(x, y, badResult);
  std::complex<double> goodResult = goodComplex(x, y);
  std::cerr << badResult << " " << goodResult << std::endl;
  return 0;
}

 

0 Kudos
3 Replies
Kittur_G_Intel
Employee
57 Views

Hi Mason,
This is a bug that got fixed in the subsequent versions of 12.X. BTW, the latest version released is 15.X which you can upgrade as well?
_Kittur

Kittur_G_Intel
Employee
57 Views

BTW, the link at  https://software.intel.com/en-us/articles/older-version-product/?wapkw=ALL(older+versions+of+softwar...  describes how to download older vesions...

_Kittur 

Bernard
Black Belt
57 Views

Strange result indeed. I suppose that reference to complex<double> badResult was pointing to uninitialized memory.

Reply