[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#429657: gcc-4.1: optimisation bug abs() in nested if



Jasen Betts <jasen@free.net.nz> writes:

> Package: gcc-4.1
> Version: 4.1.1-21
> Severity: normal
>
>
> abuse-sdl-0.7.0 has a gun aiming problem due to a mis-optimisation.
> attached is a canned example. 
>
> (compile with -01 and -02 and compare the differences)

I can confirm this on i386, but not amd64 or alpha. A shorter test
case is:

int abs(int j);
void abort(void);

int lisp_atan2(long dy, long dx) {
    if (dx <= 0)
        if (dy > 0)
            return abs(dx) <= abs(dy);
}

int main()
{
    volatile long dy = 63, dx = -77;
    if (lisp_atan2(dy, dx))
        abort();

    return 0 ;
}


-- 
	Falk



Reply to: