[Bug c/71538] Obvious optimization related to arrays aren't performed.

2016-06-15 Thread sasho648 at gmail dot com
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

[Bug c/71538] Obvious optimization related to arrays aren't performed.

2016-06-15 Thread sasho648 at gmail dot com
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?

[Bug c/71538] Obvious optimization related to arrays aren't performed.

2016-06-15 Thread rguenth at gcc dot gnu.org
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.

[Bug c/71538] Obvious optimization related to arrays aren't performed.

2016-06-14 Thread sasho648 at gmail dot com
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).