[Bug c/56956] ftrapv traps on valid abs-like code

2015-10-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #8 from Richard Biener --- Yeah, unfortunately that doesn't look correct :( I've always wanted to have an ABS_EXPR variant that returns an unsigned value (so with no undefined behavior). Maybe just overload ABS_EXPR in this way. You

[Bug c/56956] ftrapv traps on valid abs-like code

2015-10-22 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed|

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread sunfish at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #6 from Dan Gohman 2013-04-15 05:14:27 UTC --- (In reply to comment #3) > Pulling the unary minus out into a separate statement, like this: > > uint64_t y = -x; > return x <= INT64_MAX ? x : -y; > > causes the program

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread sunfish at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #5 from Dan Gohman 2013-04-15 05:12:30 UTC --- (In reply to comment #4) > (In reply to comment #2) > > (In reply to comment #1) > > > I think 'x' can not present negative value. > > > > The unary minus operator is defined for unsign

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread jasonwucj at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #4 from Chung-Ju Wu 2013-04-15 04:18:13 UTC --- (In reply to comment #2) > (In reply to comment #1) > > I think 'x' can not present negative value. > > The unary minus operator is defined for unsigned types. It doesn't produ

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread sunfish at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #3 from Dan Gohman 2013-04-15 03:54:32 UTC --- Pulling the unary minus out into a separate statement, like this: uint64_t y = -x; return x <= INT64_MAX ? x : -y; causes the program to execute correctly.

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread sunfish at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 --- Comment #2 from Dan Gohman 2013-04-15 03:53:10 UTC --- (In reply to comment #1) > I think 'x' can not present negative value. The unary minus operator is defined for unsigned types. It doesn't produce signed overflow.

[Bug c/56956] ftrapv traps on valid abs-like code

2013-04-14 Thread jasonwucj at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56956 Chung-Ju Wu changed: What|Removed |Added CC||jasonwucj at gmail dot com --- Co