This is the mail archive of the gcc@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]
Other format: [Raw text]

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



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