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]

default constructor replaces explicit definition


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




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