This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Code compiled with 2.7, doesn't with egcs, please help
- To: pliszka at cpt15 dot dur dot ac dot uk (Jacek Pliszka), egcs at cygnus dot com
- Subject: Re: Code compiled with 2.7, doesn't with egcs, please help
- From: Jason Merrill <jason at cygnus dot com>
- Date: 03 Aug 1998 14:54:35 -0700
- References: <Pine.LNX.3.96.980803154215.31234D-100000.cygnus.egcs@cpt15.dur.ac.uk>
>>>>> Jacek Pliszka <pliszka@cpt15.dur.ac.uk> writes:
> Hi!
> I had the following code:
> SMatrix::SMatrix(double_complex & d){
> ...
> };
> SMatrix::SMatrix(double x){
> double_complex cx=x;
> ((SMatrix*)this)->SMatrix(cx);
> }
> which worked with g++ 2.7.2 but when I tried to compile it
> under egcs 1.0.1, I got:
> Spinor.cc: In method `SMatrix::SMatrix(double)':
> Spinor.cc:116: no matching function for call to `SMatrix::SMatrix
> (complex<double> &)'
The problem is that constructors don't have names, so you can't call them
directly. You can only call them by creating an object of the type in
question, either through a declaration, conversion or 'new' expression.
You could change your code to do
#include <new>
...
new (this) SMatrix(cx);
Strictly speaking, I think that's not valid C++ either, since you are
effectively creating two objects in the same spot, but it ought to work.
Jason