This is the mail archive of the gcc-patches@gcc.gnu.org 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: [tree-ssa] Remove useless null pointer checks


On 31 Jul 2003, Frank Ch. Eigler wrote:
> > A.sum(A) (a)
> > {
> >   [...]
> >   T.3 = a->i;
> >   if (a == 0B)
> >     {
> >       _Jv_ThrowNullPointerException ()
> >     }; [...]
>
> Doesn't this look a little late?  If the a reference could be NULL,
> then it should have been checked before a->i was fetched.

In this case we rely on the SIGSEGV handler in libgcj.  Since it isn't
portable, most targets would compile the example with -fcheck-references,
and a->i would indeed be preceded with a null check.

> Also, can you spell out why exactly you consider this check (assuming
> its location was corrected) useless?  Can some object not call
> "A.sum(null);" ?

Yes, and a->i would trap.

Jeff


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