[Bug libstdc++/65329] [C++14] constexpr complex::real(), imag() are non-const
pipping at exherbo dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 17 17:29:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65329
Elias Pipping <pipping at exherbo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pipping at exherbo dot org
--- Comment #4 from Elias Pipping <pipping at exherbo dot org> ---
For future reference and anyone else trying to understand this bug, a bit more
info:
The fix in r216258 makes something like the following compile in C++14 mode
again:
#include <complex>
int
main()
{
std::complex<int> const x(1,2);
int r = x.real();
}
The fact that int is used as the template parameter of std::complex is
important here: float, double, and long double are handled through a
specialisation that had already been adjusted in r198141.
Since the effect of instantiating std::complex<T> where T is anything other
than one of those three floating point types is unspecified, types like
std::complex<int> are probably hardly ever used except by accident; it thus
makes sense that it took two years for someone to come across this (although I
guess instead of int, users will probably typically plug in custom floating
point types).
More information about the Gcc-bugs
mailing list