Article View: gnu.g++.bug
Article #549new/this and constructors
From: Paul Vaughan
Date: Thu, 26 Oct 1989 15:29
Date: Thu, 26 Oct 1989 15:29
61 lines
2351 bytes
2351 bytes
This code compiles under 1.35.1, but not under 1.36. The code
is annotated with the error given by the 1.36 compiler, on the line
that it mentioned.
class A {
public:
A() {}
};
class B {
public:
B(A* a = new A)
{} // sorry, not implemented: that operation not supported for default parameters
};
main() {
A a;
}
This is how it was compiled
[1.132]puma) /usr/local/gnu/1.36/bin/g++ -v -Dv136 -g -B/usr/local/gnu/1.36/lib/gcc- -g -O -DX11 -I/usr/local/gnu/1.36/lib/g++-include -o args args.cc -L/usr/local/gnu/1.36/lib -lg++ -llwp -lX11 -lm
gcc version 1.36
/usr/local/gnu/1.36/lib/gcc-cpp -+ -v -Dv136 -DX11 -I/usr/local/gnu/1.36/lib/g++-include -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 args.cc /usr/tmp/cca01499.cpp
GNU CPP version 1.36
/usr/local/gnu/1.36/lib/gcc-cc1plus /usr/tmp/cca01499.cpp -quiet -dumpbase args.cc -g -O -version -o /usr/tmp/cca01499.s
GNU C++ version 1.36.0- (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
The version of 1.36 is less than 2 weeks old. I also tried it on
another instance of 1.36 that was created by someone else, just to
check for incorrect installation.
-------------------------------------------------------------------
This is on a different subject, and I'm not sure if it is a bug or
not. g++ currently accepts the following code.
struct D;
struct C {
C(D*) {};
};
struct D : public C {
D() : C(this) {}
};
main() {
D d;
}
Note that this code passes a pointer to the uninitialized D object to
the C constructor. The C constructor could conceivably use members of
an unitialized object. I haven't been able to find anything about
this in Lippman's book, and I don't have the reference manual, but
this seems basically wrong.
Technical Details
Message-ID:
<8910261529.AA01545@puma.cad.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.comShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.com From: vaughan%cadillac.cad.mcc.com@MCC.COM (Paul Vaughan) Newsgroups: gnu.g++.bug Subject: new/this and constructors Message-ID: <8910261529.AA01545@puma.cad.mcc.com> Date: 26 Oct 89 15:29:05 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 61