------- Comment #2 from pinskia at physics dot uc dot edu  2006-07-24 22:01 
-------
Subject: Re:   New: with -O, casting result of round(x) to uint64_t produces
wrong values for x > INT_MAX

> 
> When compiling with -O or greater optimization, and if x > INT_MAX, then code
> like this:
>      uint64_t y = (uint64_t)round(x);
> assigns the wrong value to y (the top 32 bits are all 1s).  But this code
> assigns the right value to z:
>      double dz = round(x);
>      uint64_t z = dz;
> 
> It almost seems as if gcc -O in some cases compiles using a built-in
> declaration of round() that returns a 32-bit int.

Yes this is wrong code, GCC is generating for some reason lround instead of
llround.


Thanks,
Andrew Pinski


-- 


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

Reply via email to