Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!NSFNET-RELAY.AC.UK!gordon%stats.ucl.ac.uk From: gordon%stats.ucl.ac.uk@NSFNET-RELAY.AC.UK (Gordon Joly) Newsgroups: gnu.g++.bug Subject: Re: no error message when non-existent constructor is called. Message-ID: <8908161732.AA00702@AENEAS.MIT.EDU> Date: 16 Aug 89 16:28:54 GMT Sender: bob@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 56 | Michael et. al. -- | | G++ 1.35.0 on a uvax3. | | Consider the following program: | | -------------------------------------------------- | #include| | 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