This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |