Hello,
It seems that the implementation of DR 387 in trunk's <complex> is incomplete:
both versions of operator+,-(const _Tp&) still assume real() is an lvalue (see
below). These are the only offenders , AFAICS.
Is somebody on this, or should I file a PR?
Regards, Jan.
The program:
#include <complex>
typedef std::complex<double> C;
C f1(C& c) { return c+1.0; }
C f2(C& c) { return c-1.0; }
C f3(C& c) { return 1.0+c; }
C f4(C& c) { return 1.0-c; }
$ g++ -std=c++0x -c t.cpp
In file included from t.cpp:1:
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:
In function ‘std::complex<_Tp> std::operator+(const std::complex<_Tp>&, const
_Tp&) [with _Tp = double]’:
t.cpp:3: instantiated from here
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:336:
error: lvalue required as left operand of assignment
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:
In function ‘std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const
_Tp&) [with _Tp = double]’:
t.cpp:4: instantiated from here
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:366:
error: lvalue required as left operand of assignment
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:
In function ‘std::complex<_Tp> std::operator+(const _Tp&, const
std::complex<_Tp>&) [with _Tp = double]’:
t.cpp:5: instantiated from here
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:345:
error: lvalue required as left operand of assignment
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:
In function ‘std::complex<_Tp> std::operator-(const _Tp&, const
std::complex<_Tp>&) [with _Tp = double]’:
t.cpp:6: instantiated from here
/home/jan/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/complex:375:
error: lvalue required as left operand of assignment