This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ and Java CNI: Check Java references


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]