Using gcc 4.7:
$ gcc --version gcc (GCC) 4.7.0 20120505 (prerelease)
Code List (test.c):
#include <stdint.h> struct test { int before; char start[0]; unsigned int v1; unsigned int v2; unsigned int v3; char end[0]; int after; }; int main(int argc, char **argv) { int x, y; x = ((uintptr_t)(&((struct test*)0)->end)) - ((uintptr_t)(&((struct test*)0)->start)); y = ((&((struct test*)0)->end)) - ((&((struct test*)0)->start)); return x + y; }
Compile and execute
$ gcc -Wall -o test test.c && ./test Floating point exception
SIGFPE is called the second destination (y = ...). Is there a division in the assembly sheet on this line? Note that the only difference between x = and y = is to call (uintptr_t).
Wade source share