Some tests in gcc.c-torture rely on undefined behaviour?
Robert Dewar
dewar@adacore.com
Wed Jul 13 19:58:00 GMT 2005
Nicholas Nethercote wrote:
> Hi,
>
> I've been looking at the gcc.c-torture tests, it seems some of them rely
> on undefined behaviour. For example, 920612-1.c looks like this:
>
> f(j)int j;{return++j>0;}
> main(){if(f((~0U)>>1))abort();exit(0);}
>
> AIUI, this passes the largest possible positive integer to f(), which
> then increments it, causing signed overflow, the result of which is
> undefined. The test passes if signed overflow wraps.
>
> 930529-1.c is similar -- again the maximum positive integer is incremented.
i think it is fine 2 have these tests. ant gcc version failing them is suspicious
More information about the Gcc
mailing list