This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: volatile std::complex<> problem
- From: jhr dot walter at t-online dot de (Joerg Walter)
- To: <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 7 Mar 2003 10:21:11 +0100
- Subject: Re: volatile std::complex<> problem
Hi,
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