C++ and Java CNI: Check Java references
Mark Mitchell
mark@codesourcery.com
Wed Apr 25 11:57:00 GMT 2001
>>>>> "Mike" == Mike Harrold <mharrold@cas.org> writes:
Mike> only thing the compiler knows is that references SHOULD
Mike> never be NULL.
The point is that the compiler can assume references are never NULL
and optimize accordingly.
If you break the rules, the compiler may or may not generate code that
behaves like you expect. For example, if you write:
void h(X& x) {
if (&x == 0) f();
else g();
}
The compiler may just turn this into:
void h(X& x) {
g();
}
If you expect `f' to be called when you pass `h' something like:
`*((X*) 0)', you will be disappointed.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Java
mailing list