default constructor replaces explicit definition

Chris Jang cjang@ix.netcom.com
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.

Thanks,
Chris Jang


#include <iostream.h>

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

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

  return 0;
}





More information about the Gcc-bugs mailing list