Bug 24242

Summary: Redundant null pointer checks generated on refrerences returned by new operator.
Product: gcc Reporter: David Daney <daney>
Component: javaAssignee: Andrew Pinski <pinskia>
Status: RESOLVED DUPLICATE    
Severity: enhancement CC: daney, gcc-bugs, green, java-prs, sabre
Priority: P2 Keywords: missed-optimization
Version: 4.1.0   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed: 2005-10-06 17:35:53
Bug Depends on: 19476, 20318    
Bug Blocks:    

Description David Daney 2005-10-06 17:27:33 UTC
When examining the assembler output (compiled with -O2) from this class:

public class T
{
    Object f1()
    {
        Object o = new Object();

        return o.getClass();
    }
}

We see a check for a null return value from _Jv_AllocObjectNoFinalizer (i.e. the new operator).

However _Jv_AllocObjectNoFinalizer always returns non-null values.  On out-of-memory it throws an OutOfMemoryError
Comment 1 Andrew Pinski 2005-10-06 17:35:53 UTC
Confirmed, just like the example in PR 19476 for the C++ case.
Comment 2 Andrew Pinski 2005-11-12 20:06:18 UTC
Will look into marking _Jv_AllocObjectNoFinalizer with the non zero attribute which is added with PR 20318.
Comment 3 Andrew Pinski 2005-11-12 20:09:05 UTC
This is actually a dup of bug 21856.

*** This bug has been marked as a duplicate of 21856 ***