- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When compiling the following simple test file, #include int main () { std::complex a(1, 1); double r = std::real(a); double i = std::imag(a); return 0; } With icpc -std=c++11 on RHEL 6.3 with GCC4.7 installed as the default GCC (g++ --version shows 4.7.1), the following error messages are emitted, $ icpc -std=c++11 -o foo foo.cpp /opt/gcc/include/c++/4.7.1/complex(536): error: no instance of overloaded function "std::complex::real" matches the argument list and object (the object has cv-qualifiers that prevent a match) object type is: const std::complex { return __z.real(); } ^ detected during instantiation of "_Tp std::real(const std::complex &) [with _Tp=double]" at line 6 of "foo.cpp" /opt/gcc/include/c++/4.7.1/complex(541): error: no instance of overloaded function "std::complex::imag" matches the argument list and object (the object has cv-qualifiers that prevent a match) object type is: const std::complex { return __z.imag(); } ^ detected during instantiation of "_Tp std::imag(const std::complex &) [with _Tp=double]" at line 7 of "foo.cpp" The relevant GCC header is as below. #ifdef __GXX_EXPERIMENTAL_CXX0X__ // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 387. std::complex over-encapsulated. constexpr _Tp- real() { return _M_real; } constexpr _Tp- imag() { return _M_imag; } #else /// Return real part of complex number. _Tp&- real() { return _M_real; } /// Return real part of complex number. const _Tp&- real() const { return _M_real; } /// Return imaginary part of complex number. _Tp&- imag() { return _M_imag; } /// Return imaginary part of complex number. const _Tp&- imag() const { return _M_imag; } #endif It seems icpc insists on the const version of the member functions while GCC4.7's version only provide them in the non-C++11 mode. I am not familiar with the standard. Is this a bug of icpc or GCC header? g++ can compile the above file without any problem.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An update to this issue. It has been fixed in the 13.0 update 2 and newer.
Jennifer

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page