Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Gordon Joly
Wed, 16 Aug 1989 16:28
Re: no error message when non-existent constructor is called.
Author: Gordon Joly
Date: Wed, 16 Aug 1989 16:28
Date: Wed, 16 Aug 1989 16:28
56 lines
2453 bytes
2453 bytes
| Michael et. al. --
|
| G++ 1.35.0 on a uvax3.
|
| Consider the following program:
|
| --------------------------------------------------
| #include <stream.h>
|
| struct foo {
| public:
| foo();
| private:
| int i;
| };
|
| foo::foo() { cout << "Hello.\n"; }
|
| void main() {
| foo f(7);
| }
| --------------------------------------------------
|
| This should give an error message, because there is no "foo"
| constructor that takes an integer argument. Instead if gives no
| argument. Even more insidious, it does not call the default
| constructor -- when run, the above program prints nothing.
|
| Thanks. Ad astra.
|
| Dave
|
Al speaking; on a SUN-3/160 with g++ 1.36.0-, libg++ 1.35.1, gas 1.34, SUN OS 4.0.1.
karl:/stats/staff/karl/gordon/c++[66] g++ -v -g -Wall -lg++ -lm test5.cc -o test5
g++ version 1.36.0-
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__GNUC__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 test5.cc /tmp/cca14086.cpp
GNU CPP version 1.35.96
/usr/local/lib/gcc-cc1plus /tmp/cca14086.cpp -quiet -dumpbase test5.cc -Wall -noreg -version -G -o /tmp/cca14086.s
GNU C++ version 1.36.0- (68k, MIT syntax) compiled by GNU C version 1.35.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
test5.cc: In function void main ():
test5.cc:13: invalid initializer to constructor for type `foo'
test5.cc:13: warning: unused variable `f'
karl:/stats/staff/karl/gordon/c++[67]
Gordon (you can call me Al) Joly.
Surface mail: Dr. G.C.Joly, Department of Statistical Science,
University College London, Gower Street, LONDON WC1E 6BT, U.K.
E-mail: | Tel: +44 1 387 7050
JANET (U.K. network) gordon@uk.ac.ucl.stats | extension 3636
ARPA gordon@stats.ucl.ac.uk[@nsfnet-relay.ac.uk] | FAX: +44 1 387 8057
Relays: EAN: @ean-relay.ac.uk UUCP: ...!uunet.uu.net!ucl-stats!gordon
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads