public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode)
@ 2013-07-09 8:04 su at cs dot ucdavis.edu
2013-07-10 13:25 ` [Bug middle-end/57859] " mikpe at it dot uu.se
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-07-09 8:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57859
Bug ID: 57859
Summary: -ftrapv does not trap on signed overflows for struct
fields (32-bit mode)
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The following code (which has a signed integer overflow) doesn't trap when
compiled at -O1 or above with -ftrapv on x86_64-linux. This applies to the
current gcc trunk, as well as gcc-4.6, gcc-4.7, and gcc-4.8.
$ gcc-trunk -v
gcc version 4.9.0 20130708 (experimental) [trunk revision 200751] (GCC)
$ gcc-trunk -m32 -O0 -ftrapv small.c
$ a.out
Aborted (core dumped)
$ gcc-trunk -m32 -O1 -ftrapv small.c
$ a.out
$ gcc-4.8 -m32 -O1 -ftrapv small.c
$ a.out
$ gcc-4.7 -m32 -O1 -ftrapv small.c
$ a.out
$ gcc-4.6 -m32 -O1 -ftrapv small.c
$ a.out
$
-------------------------------------------
struct S
{
int f;
};
int
main ()
{
struct S s;
for (s.f = 1; s.f > 0; ++s.f)
;
return 0;
}
-------------------------------------------
The following code does trap in 32-bit mode (but still not in 64-bit):
int
main ()
{
int i;
for (i = 1; i > 0; ++i)
;
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/57859] -ftrapv does not trap on signed overflows for struct fields (32-bit mode)
2013-07-09 8:04 [Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode) su at cs dot ucdavis.edu
@ 2013-07-10 13:25 ` mikpe at it dot uu.se
2013-11-09 22:31 ` pinskia at gcc dot gnu.org
2015-07-05 12:14 ` mikpelinux at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: mikpe at it dot uu.se @ 2013-07-10 13:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57859
--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> ---
With -m64: both test cases work with gcc-3.2.3, and fail with every release
from 3.3.6 up to current trunk.
With -m32: the first test case doesn't trap with any release since 3.2.3, the
second test case traps with current trunk and 4.8, but not with any release
from 3.2.3 to 4.7.3.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/57859] -ftrapv does not trap on signed overflows for struct fields (32-bit mode)
2013-07-09 8:04 [Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode) su at cs dot ucdavis.edu
2013-07-10 13:25 ` [Bug middle-end/57859] " mikpe at it dot uu.se
@ 2013-11-09 22:31 ` pinskia at gcc dot gnu.org
2015-07-05 12:14 ` mikpelinux at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-11-09 22:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57859
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-11-09
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-ftrapv is very broken right now. There are some changes going to happen to
add -fundefined=overflow soon which should replace fully -ftrapv to be more
correct implementation.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/57859] -ftrapv does not trap on signed overflows for struct fields (32-bit mode)
2013-07-09 8:04 [Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode) su at cs dot ucdavis.edu
2013-07-10 13:25 ` [Bug middle-end/57859] " mikpe at it dot uu.se
2013-11-09 22:31 ` pinskia at gcc dot gnu.org
@ 2015-07-05 12:14 ` mikpelinux at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: mikpelinux at gmail dot com @ 2015-07-05 12:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57859
--- Comment #3 from Mikael Pettersson <mikpelinux at gmail dot com> ---
-ftrapv seems to be working a bit better in gcc-6: only the first test case
fails (doesn't report the overflow) at -O1/2 for both -m32/-m64, but all other
combinations of test case, -O0 vs -O1/2, and -m32 vs -m64, seem to work.
However, since -fsanitize=undefined works since 4.9, should -ftrapv be
deprecated and this bug be closed as WONTFIX?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-05 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 8:04 [Bug middle-end/57859] New: -ftrapv does not trap on signed overflows for struct fields (32-bit mode) su at cs dot ucdavis.edu
2013-07-10 13:25 ` [Bug middle-end/57859] " mikpe at it dot uu.se
2013-11-09 22:31 ` pinskia at gcc dot gnu.org
2015-07-05 12:14 ` mikpelinux at gmail dot com
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).