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


jsturm wrote:

> [...] Java emits tons of useless null pointer checks.
> Without this patch, the class:
> 
> class A { 
>   int i;
>   final int j() { return i; }
>   static int sum(A a) { return a.i + a.j(); }
> }

> would optimize to (in method sum):
> 
> 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.

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);" ?


- FChE


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