This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Remove useless null pointer checks
- From: Jeff Sturm <jsturm at one-point dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 Jul 2003 13:23:43 -0400 (EDT)
- Subject: 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