C++ overload resolution of _Quad and complex _Quad types
I'm having trouble using the 128-bit extended/quad precision floating point types in C++. It seems that the overload resolution is not distinguishing correctly between the real and the complex 128-bit types:
Compiling it with $ icpc -Qoption,cpp,--extended_float_type -o test1 test1.cc
I get the output: Called fff(double) Called fff(complex double) Called fff(quad) Called fff(quad)
looking at the symbols: $ nm test1 | grep fff 0000000000400a40 T _Z3fffCd 0000000000400a30 T _Z3fffd 0000000000400a20 T _Z3fffg
I see that while there are the two overloaded functions for double and complex double, there is only one funciton generated for quad, and the complex quad function is completely missing. It seems that both '_Quad' and 'complex _Quad' get mangled to the same name, so the linker eliminates the second one.
Running the same under gcc (with the other set of #define's uncommented for its quad type): $ g++ -o test1 test1.cc
the output: Called fff(double) Called fff(complex double) Called fff(quad) Called fff(complex quad)
$ nm test1 | grep fff 00000000004005bd T _Z3fffCd 0000000000400604 T _Z3fffCg 00000000004005a4 T _Z3fffd 00000000004005eb T _Z3fffg
all the overloaded functions are accounted for.
I know that there is a C++ complex<> template that can be used, and that I am using the C99 complex type, the reason for not using it has to do with performance.
The compiler is the latest 64-bit icpc: $ icpc -V Intel C++ Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100414
I have reproduced your issue with Intel compiler. However, for g++ 4.2.x , I get the same result & name-mangling as with Intel compiler. And with other like g++ 4.4 & 4.3.x, I cannot even compile, as those _Quad, and complex keywords are not recognized. May be I am doing something wrong.
However, I have escalated this issue to the developer team, and will let you know on this. The bug record is:-- DPD200155329
Yes, gcc has a different keyword for _Quad and complex _Quad, so you need to uncomment the other pair of #define's in the sample code (__float128 and that other somewhat confusing definition for the complex type).