public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/56956] New: ftrapv traps on valid abs-like code
@ 2013-04-14 19:14 sunfish at google dot com
  2013-04-15  0:58 ` [Bug c/56956] " jasonwucj at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sunfish at google dot com @ 2013-04-14 19:14 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956

             Bug #: 56956
           Summary: ftrapv traps on valid abs-like code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sunfish@google.com


This program aborts when compiled with -ftrapv, despite not having any
overflow:

#include <limits.h>
#include <inttypes.h>
#include <stdio.h>

__attribute__((noinline))
uint64_t foo(uint64_t x) {
  return x <= INT64_MAX ? x : -x;
}

int main() {
  uint64_t n = foo((uint64_t)INT64_MIN);
  printf("%" PRIx64 "\n", n);
  return 0;
}

It appears that the code in foo is being folded into an absolute-value
expression which does not work properly on INT64_MIN. However, the code as
written does  handle INT64_MIN without any signed overflow.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-10-29  8:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-14 19:14 [Bug c/56956] New: ftrapv traps on valid abs-like code sunfish at google dot com
2013-04-15  0:58 ` [Bug c/56956] " jasonwucj at gmail dot com
2013-04-15  3:53 ` sunfish at google dot com
2013-04-15  3:54 ` sunfish at google dot com
2013-04-15  4:18 ` jasonwucj at gmail dot com
2013-04-15  5:12 ` sunfish at google dot com
2015-10-22 11:15 ` mpolacek at gcc dot gnu.org
2015-10-22 12:09 ` rguenth at gcc dot gnu.org
2015-10-28 11:20 ` [Bug middle-end/56956] " rguenth at gcc dot gnu.org
2015-10-29  8:22 ` rguenth at gcc dot gnu.org
2015-10-29  8:24 ` [Bug middle-end/56956] [4.9/5 Regression] " rguenth at gcc dot gnu.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).