User account creation filtered due to spam.

Bug 25418 - ftrapv sometimes does not emit checking for addition
Summary: ftrapv sometimes does not emit checking for addition
Status: RESOLVED DUPLICATE of bug 19020
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2005-12-14 18:20 UTC by Christopher Chua
Modified: 2005-12-14 18:32 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Chua 2005-12-14 18:20:05 UTC
Compile the following C program for x86 (mingw, i686) using "gcc -ftrapv -S -O0 <filename>" (Note: Includes omitted for brevity; GCC will warn. Including stdio.h or stdlib.h does not fix the bug):

int main(void)
	int a,b;
	printf("Enter two signed int values: ");
	scanf("%d %d",&a,&b);
	printf("\na + b = %d, a * b = %d, a - b = %d\n",a+b,a*b,a-b);

The assembly listing produced does not include a call to __addvsi3. It does, however, contain calls to __subvsi3 and __mulvsi3. This occurs at all optimisation levels with GCC 4.0.2.

I also tested this with GCC 3.4.0 (RedHat Linux 9, i686). The call to __addvsi3 is correctly done at -O0 and -O1, but not at any higher optimisation levels, where it is replaced by an explicit "addl".
Comment 1 Andrew Pinski 2005-12-14 18:32:28 UTC

*** This bug has been marked as a duplicate of 19020 ***