This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: volatile std::complex<> problem


talking with myself ;-):

> the following program
> #include <complex>
> int main()
> {
>   std::complex<double> c1, c2;
>   volatile std::complex<double> c3(c1 + c2); // works fine
>   volatile std::complex<double> c4;
>   c4 = c1 + c2; // fails
> }
> doesn't compile with GCC 3.2.1 (and GCC 2.95.3)
> Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
> Configured with: ./configure
> Thread model: posix
> gcc version 3.2.1
> giving the diagnostic
> volatileness.cpp: In function `int main()':
> volatileness.cpp:7: passing `volatile std::complex<double>' as `this'
> argument
>    of `std::complex<double>& std::complex<double>::operator=(const
>    std::complex<double>&)' discards qualifiers
> ICC 7.0 and Kylix accept the program. Is this a well known deficiency?

Correction: ICC 7.0 doesn't accept the above program if in strict ANSI mode
(as do a couple of other compilers).

The problem seems to be a non specified volatile qualified assignment
operator of std::complex.

I'm pretty unsure, if this couldn't be a problem in multithreading contexts.

Sorry for the noise,

Joerg Walter

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]