[Bug tree-optimization/86732] Potential nullptr dereference does not propagate knowledge about the pointer

law at redhat dot com gcc-bugzilla@gcc.gnu.org
Thu Aug 2 22:50:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86732

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at redhat dot com

--- Comment #5 from Jeffrey A. Law <law at redhat dot com> ---
The code is working as designed.  As noted, we want the dereference to occur so
that programs can catch the signal that occurs as a result of the dereference.

Using __builtin_trap is definitely better from a security standpoint because
the program halts after the undefined behavior -- consider an mmu-less system
that doesn't trap on *0.  If you use __builtin_unreachable you'll just start
executing random code which would be a wonderful attack vector.

And FWIW, I think we should be using __builtin_trap rather than
__builtin_unreachable in many more places because of the security concerns.


More information about the Gcc-bugs mailing list