This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Integer overflow in operator new
- From: "J.C. Pizarro" <jcpiza at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 9 Apr 2007 03:35:45 +0200
- Subject: Re: Integer overflow in operator new
One instruction more in GCC-4.1.x vs GCC-3.4.6?
Joe Buck's code: 10 instructions [ -Os of gcc-4.1.3-20070326 ]
__compute_size:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movl %eax, %edx
imull 12(%ebp), %edx
cmpl %eax, %edx
orl $-1, %edx
popl %ebp
movl %edx, %eax # <--- this extra instruction because return EAX = EDX?
ret
Joe Buck's code: 9 instructions [ -Os of gcc-3.4.6 ]
__compute_size:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %edx
movl %edx, %eax
imull 12(%ebp), %eax
cmpl %edx, %eax
orl $-1, %eax
popl %ebp
# <--- no extra instruction because return EAX = EAX?
ret
J.C. Pizarro