This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
same object is constructed, then destructed, twice
- To: egcs-bugs at cygnus dot com
- Subject: same object is constructed, then destructed, twice
- From: Corey Kosak <kosak at cs dot cmu dot edu>
- Date: Tue, 06 Jan 1998 23:19:29 -0500
Hi,
% g++ -v
Reading specs from /usr2/aloco/lib/gcc-lib/alpha-dec-osf3.2/egcs-2.91.03/specs
gcc version egcs-2.91.03 971225 (gcc-2.8.0)
% g++ twice.cc other.cc
/usr/bin/ld:
Warning: Linking some objects which contain exception information sections
and some which do not. This may cause fatal runtime exception handling
problems (last obj encountered without exceptions was /usr2/aloco/lib/libstdc++.a).
/usr/bin/ld:
Warning: Linking some objects which contain exception information sections
and some which do not. This may cause fatal runtime exception handling
problems (last obj encountered without exceptions was /usr2/aloco/lib/libstdc++.a).
% a.out
Constructing a cow at 0x140003f50
Constructing a cow at 0x140003f50
Destructing a cow at 0x140003f50
Destructing a cow at 0x140003f50
% cat twice.h
class cow {
public:
cow() { cerr <<"Constructing a cow at " <<this <<"\n"; }
~cow() { cerr <<"Destructing a cow at " <<this <<"\n"; }
};
inline void moo()
{
static cow x;
}
% cat twice.cc
#include <iostream.h>
#include "twice.h"
int main()
{
extern void other();
other();
moo();
}
% cat other.cc
#include <iostream.h>
#include "twice.h"
void other()
{
moo();
}