Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Intel 12 Floating Point Optimization -- complex<double>

Mason_W_
Beginner
273 Views

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
KitturGanesh
Employee
273 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

0 Kudos
KitturGanesh
Employee
273 Views

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

_Kittur 

0 Kudos
Bernard
Valued Contributor I
273 Views

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

0 Kudos
Reply