This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug in gcc version 2.95.2 19991024 (release): member initialization with new
- To: "'bug-gcc at gnu dot org'" <bug-gcc at gnu dot org>
- Subject: bug in gcc version 2.95.2 19991024 (release): member initialization with new
- From: Erik Eckstein <Eckstein at atair dot co dot at>
- Date: Wed, 14 Jun 2000 16:48:10 +0200
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
[...]