[gnu.g++.bug] `new T

eggert@burns.twinsun.com (Paul Eggert) (09/14/89)

G++ 1.35 ignores initializers of `new' if no constructor is defined for the
corresponding class.  An error message should be issued instead.
Here is an example.

	struct complex { int re, im; };

	main()
	{
		complex *zp1 = new complex(5,10);
		return zp1->re;
	}

`main()' yields garbage (that happens to be zero) when compiled by G++ 1.35
(Sun-3/50 + SunOS 4.0.3).  Here is the Sun-3 assembly language output:

	#NO_APP
	gcc_compiled.:
	.text
		.even
	.globl _main
	_main:
		link a6,#-4
		pea 8:w
		jbsr ___builtin_new
		movel d0,a6@(-4)
		movel a6@(-4),a0
		movel a0@,d1
		movel d1,d0
		jra L1
	L1:
		unlk a6
		rts

The 5 and 10 were silently ignored.  Instead, the error message "constructor
syntax used, but no constructor declared for type `complex'" should have been
issued.  Such a message is correctly issued for the following program, which
makes a similar error without `new'.

	struct complex { int re, im; };

	main()
	{
		complex zp1(5,10);
		return zp1.re;
	}