default constructor replaces explicit definition

Chris Jang
Sat Jan 30 12:35:00 GMT 1999

Hello egcs-bugs,

First, thanks for all of the work. It is appreciated very much. I'm using
egcs-1.1b on what was originally a K6 based RedHat 4.2 system but since
has been upgraded substantially as regards kernel and libraries.

The code below shows the problem. Depending on how the stack instance of a
MyUndefinedClass is declared, the user defined default constructor may be
optimized away in favor of one generated by the compiler.

If someone else has sent this in, sorry for the bother.

Chris Jang

#include <iostream.h>

class MyUndefinedClass
  MyUndefinedClass() { cout << "electro vlassic" << endl << flush; }

main(int argc, char **argv)
#if 0
  // nothing is printed to standard out
  MyUndefinedClass bad();
  // "electro vlassic" is printed to standard out
  MyUndefinedClass good;

  return 0;

More information about the Gcc-bugs mailing list