[Bug c/63803] When GCC 4.9.2 compile with option -O2, the target is error.
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Nov 10 11:21:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63803
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Airbak from comment #3)
> 2.
> *((unsigned int *)0) is OK
> *((volatile unsigned int *)0) is not OK.
> Why the "volatile" makes different?
Because volatile prevents the compiler from optimizing that statement out. As
stated above, dereferencing a NULL pointer is undefined, so if you do that, all
bets are off.
You can use -fno-isolate-erroneous-paths-dereference, but I think the problem
is elsewhere.
More information about the Gcc-bugs
mailing list