Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dewing__Mark
Beginner
95 Views

Implicit conversions for std::complex

Passing a std::complex<float> constant to a function that takes a std::complex<double> argument receives the wrong real part inside the function.    Passing a std::complex variable produces the expected result.   Changing the function to accept a value rather than a const reference makes no difference.

#include <complex>
#include <iostream>

void f(const std::complex<double> &val)   // or void f(std::complex<double> val)
{
    std::cout << "In f1, val = " << val << std::endl;
}

int main()
{

    f(std::complex<float>(1,2));   // Fails

    std::complex<float> b(1,2);
    f(b);  // Works
    

    return 0;
}

Produces the output:

In f1, val = (2,2)
In f1, val = (1,2)

 

This is with the Intel compiler 19.0.4.243.    GCC and clang give the expected results.

 

0 Kudos
1 Reply
Viet_H_Intel
Moderator
95 Views

Thanks for reporting this issue. I've submitted a bug #CMPLRIL0-32033 to the compiler Developer.

Reply