https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71538
--- Comment #4 from sasho648 at gmail dot com ---
More *shocking* example will be:
struct tx { int a[6], b[6]; } *f();
void (main)()
{
int *p = f()->b;
if(p == NULL)
printf("What?");
}
Compiling with "gcc -Of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71538
--- Comment #3 from sasho648 at gmail dot com ---
But if it's NULL for the cast it'll invoke UB I believe. Shouldn't the
optimizer assume that UB never occur?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71538
--- Comment #2 from Richard Biener ---
I don't think the C standard says that p cannot be a NULL pointer for this
cast.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71538
--- Comment #1 from sasho648 at gmail dot com ---
The exact command used to compile this code was "gcc -O3 test.c" (as test.c
containing the snippet above).