This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

same object is constructed, then destructed, twice



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();
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]