This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New attribute: returns_nonnull

On 10/10/13 08:17, Tom Tromey wrote:
      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 {
     } catch (NullPointerException _) {

     if (x == null)
That's my recollection.

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.


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