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]

bug in gcc version 2.95.2 19991024 (release): member initialization with new


Command line:

	bin/g++ -S test.c

Compiler version:

	2.95.2 19991024 (release)

Target:

	Intel x86

Source code:

	class X
	{
	 public:
	        X(int n);
	        int *a;
	};

	X::X(int n) : a(new (int[n]))
	{ }

Behaviour:

	The size argument to new (sizeof(int) * n) is incorrect. It depends
on the previous value of the ebx register.

Assembler output:

	[...]
	__1Xi:
	.LFB1:
	        pushl %ebp
	.LCFI0:
	        movl %esp,%ebp
	.LCFI1:
	        subl $12,%esp
	.LCFI2:
	        pushl %edi
	.LCFI3:
	        pushl %esi
	.LCFI4:
	        pushl %ebx
	.LCFI5:
	        movl 8(%ebp),%esi
	        addl $-12,%esp
	        leal 1(%ebx),%eax			<= correct
instruction would be: movl 12(%ebp),%eax
	        leal 0(,%eax,4),%edx
	        pushl %edx
	.LCFI6:
	        call __builtin_vec_new
	[...]


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