On 17 June 2011 01:27, Randalph Phelps wrote: > Hi all, > > I have noticed that gcc's std::real() and std::imag() return a reference, unless > "-std=c++0x" is specified. The C++98 standard specifies in section 26.2.7 that > these two functions have the following prototypes: > > template<class T> T real(const complex<T>&); > template<class T> T imag(const complex<T>&); > > In gcc 4.4, for example, it is: > template<typename _Tp> _Tp& real(complex<_Tp>& __z) > > Is there a reason for this deviation from the standard? This breaks for any > specializations of std::complex that return a value for real() and imag(). I would guess the reason was an attempt to address the problem discussed in DR 387: that there is no way to set the individual real and imaginary parts of a complex<T> in C++98. Someone has now opened a bugzilla report about it and I added some relevant links in a comment there, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49476