Null pointer check elimination
Gabriel Dos Reis
gdr@integrable-solutions.net
Mon Nov 14 21:56:00 GMT 2005
"Michael N. Moran" <mike@mnmoran.org> writes:
| Gabriel Dos Reis wrote:
| > "Michael N. Moran" <mike@mnmoran.org> writes:
| > | Wow. I'm sure there is sound reasoning for this ... but I can't
| > | understand what that might be given a client module could intentionally
| > | (if ill-adviseadly) simply invoke the function:
| > then it gets what it deserves. Check out GCC manual for null-pointer
| > check.
|| From info gcc:
|| `-fdelete-null-pointer-checks'
| Use global dataflow analysis to identify and eliminate useless
| checks for null pointers. The compiler assumes that dereferencing
| a null pointer would have halted the program. If a pointer is
| checked after it has already been dereferenced, it cannot be null.
|| The second sentence makes me question the difference between an
| actual dereferencing operation and the use of a dereferencing
| operator used to convert a pointer to a C++ reference. Clearly
| (to me anyway ;-) the conversion case does not actually cause
| an access to the object.
It is not a conversion. It is a dereference operation that is defined
only for non-null operand. No ifs, no buts.
-- Gaby
More information about the Java
mailing list