On 10/10/13 08:17, Tom Tromey wrote:
        In
      addition, other optimization passes in GCC use this flag to
      control global dataflow analyses that eliminate useless checks for
      null pointers; these assume that if a pointer is checked after it
      has already been dereferenced, it cannot be null.

I think the key situation is one where the code has a dereference that
is caught, followed by a null pointer check, like:
Right. That's my recollection.


     try {
       x.toString();
     } catch (NullPointerException _) {
     }

     if (x == null)
       System.out.println("ok");
That's my recollection.

http://gcc.gnu.org/ml/gcc-patches/2011-11/msg00936.html

Starts the thread where it was decided to set that flag for java


I changed java/lang.c to set x_flag_delete_null_pointer_checks and I
couldn't make this test case (or a few others) fail.

However, I'm not sure if that is because GCC understands that
-fnon-call-exceptions means that the dereference can throw, and thus
does the right thing; or whether I'm just getting lucky.
I think it was done out of an abundance of caution -- I don't think we have ever tripped over this problem in the wild.

jeff

Reply via email to