http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> 2012-12-04 09:02:00 UTC --- On Mon, 3 Dec 2012, mpreda at gmail dot com wrote: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55559 > > --- Comment #7 from Mihai Preda <mpreda at gmail dot com> 2012-12-03 22:13:03 > UTC --- > Thanks, I didn't realize that (unsigned)-1.0 is undefined. > > For the behavior I was expecting it's enough to use an intermediary cast > through int, e.g. (unsigned)(int)-1.0. Yes, that makes it implementation-defined (and all implementations I know of do what you expect, modulo-two reduction). > It may be nice to generate a consistent (-O0/-O1) result for (unsigned)-1.0 > though, even if not required by the standard. That's unfortunately generally impossible.