🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #266

Constructor not called

#266
From: Ron Sommeling
Date: Wed, 15 Apr 1992 10:00
38 lines
1510 bytes
Machine: SPARCstation 1 running SunOS 4.1.1
Compiler: g++ 2.1

% cat t.C
#include <iostream.h>

class q {
public:
	q(int i) { cout << "constructor with i = " << i << endl; }
	~q() { cout << "destructor" << endl; }
};

q a(3);

main() {
  q b(2);
}
% g++ t.C
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.1/specs
gcc version 2.1
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix t3.C /usr/tmp/cca03214.i
GNU CPP version 2.1 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.1/cc1plus /usr/tmp/cca03214.i -quiet -dumpbase t3.cc -version -o /usr/tmp/cca03214.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
 as -o t3.o /usr/tmp/cca03214.s
 ld -e start -dc -dp /lib/crt0.o -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.1/ -L/usr/local/lib/ t3.o -lg++ -lgcc -lc -lgcc
% ./a.out
constructor with i = 2
destructor


Shouldn't that be:
	constructor with i = 3
	constructor with i = 2
	destructor
	destructor

Ron Sommeling <Ron.Sommeling@cwi.nl>
Technical Details
Message-ID: <5858@charon.cwi.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cwi.NL!Ron.Sommeling

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cwi.NL!Ron.Sommeling
From: Ron.Sommeling@cwi.NL (Ron Sommeling)
Subject: Constructor not called
Message-ID: <5858@charon.cwi.nl>
Sender: gnulists@ai.mit.edu
Organization: CWI, Amsterdam
Distribution: gnu
Date: Wed, 15 Apr 1992 10:00:46 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 39