public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40143] New: -ftrapv fails to generate signal for overflows in int multiplication on x86-64
@ 2009-05-14 10:33 dickinsm at gmail dot com
2009-05-14 10:55 ` [Bug c/40143] " rguenth at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: dickinsm at gmail dot com @ 2009-05-14 10:33 UTC (permalink / raw)
To: gcc-bugs
The -ftrapv option doesn't appear to work as documented for GCC 4.4.0 on Debian
Linux 5.0/amd64. In the code below, the multiplication overflows an int, and
so I was expecting the program to be aborted. Instead, the program returned
normally with exit code 1.
Looking at the generated assembly, it seems that the multiplication
generates a call to __mulvdi3 instead of __mulvsi3.
/* begin test.c */
int mul(int x, int y) {
return x*y;
}
int main(void) {
int x = 60000, y = 65432, z;
z = mul(x, y);
return z < 0 ? 1 : 0;
}
/* end test.c */
Here's the output from gcc-4.4 -v -save-temps -ftrapv test.c:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.4.0/configure --program-suffix=-4.4
Thread model: posix
gcc version 4.4.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ftrapv' '-mtune=generic'
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/cc1 -E -quiet -v test.c
-mtune=generic -ftrapv -fpch-preprocess -o test.i
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ftrapv' '-mtune=generic'
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/cc1 -fpreprocessed
test.i -quiet -dumpbase test.c -mtune=generic -auxbase test -version -ftrapv -o
test.s
GNU C (GCC) version 4.4.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.4.0, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4d22b9ce88170f4e051ca32157922a46
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ftrapv' '-mtune=generic'
as -V -Qy -o test.o test.s
GNU assembler version 2.18.0 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.18.0.20080103
COMPILER_PATH=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/:/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/:/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ftrapv' '-mtune=generic'
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/collect2 --eh-frame-hdr
-m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/crtbegin.o
-L/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0
-L/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64
-L/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../.. test.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/crtend.o
/usr/lib/../lib64/crtn.o
--
Summary: -ftrapv fails to generate signal for overflows in int
multiplication on x86-64
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dickinsm at gmail dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40143
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/40143] -ftrapv fails to generate signal for overflows in int multiplication on x86-64
2009-05-14 10:33 [Bug c/40143] New: -ftrapv fails to generate signal for overflows in int multiplication on x86-64 dickinsm at gmail dot com
@ 2009-05-14 10:55 ` rguenth at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-05-14 10:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-05-14 10:55 -------
*** This bug has been marked as a duplicate of 35412 ***
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40143
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-14 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14 10:33 [Bug c/40143] New: -ftrapv fails to generate signal for overflows in int multiplication on x86-64 dickinsm at gmail dot com
2009-05-14 10:55 ` [Bug c/40143] " rguenth at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).