Question on signed overflow

Andrew Haley aph@redhat.com
Fri Jun 18 14:00:00 GMT 2010


On 06/18/2010 12:00 PM, Georg Lay wrote:
> Andrew Haley schrieb:
>> On 06/18/2010 10:11 AM, Georg Lay wrote:
>> What does -fdump-tree-optimized look like?
> 
> It looks almost as yours:
> 
> ;; Function abssat2 (abssat2)
> 
> Analyzing Edge Insertions.
> abssat2 (int x)
> {
>   unsigned int y;
> 
> <bb 2>:
>   y = (unsigned int) x;
>   if (x < 0)
>     goto <bb 3>;
>   else
>     goto <bb 4>;
> 
> <bb 3>:
>   y = -y;
> 
> <bb 4>:

Here may be a bug.  That's an integer overflow on unsigned-signed conversion:

>   if ((int) y < 0)
>     goto <bb 5>;
>   else
>     goto <bb 6>;
> 
> <bb 5>:
>   y = y + 0x0ffffffff;
> 
> <bb 6>:
>   return (int) y;
> 
> }

I still think that the fact that you get an incorrect overflow warning
but I don't is really important.  If we can find out why, I think that
may point to the real problem.

Andrew.



More information about the Gcc-help mailing list