This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/25418] New: ftrapv sometimes does not emit checking for addition
- From: "someone42 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Dec 2005 18:20:05 -0000
- Subject: [Bug middle-end/25418] New: ftrapv sometimes does not emit checking for addition
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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);
exit(0);
}
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".
--
Summary: ftrapv sometimes does not emit checking for addition
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: someone42 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25418