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

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).