This is the mail archive of the
java-prs@sources.redhat.com
mailing list for the Java project.
Re: gcj/304: Definate assignment with switch
- To: apbianco at cygnus dot com
- Subject: Re: gcj/304: Definate assignment with switch
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: 11 Dec 2000 00:16:00 -0000
- Cc: java-prs at sourceware dot cygnus dot com,
- Reply-To: Bryce McKinlay <bryce at albatross dot co dot nz>
The following reply was made to PR gcj/304; it has been noted by GNATS.
From: Bryce McKinlay <bryce@albatross.co.nz>
To: java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/304: Definate assignment with switch
Date: Mon, 11 Dec 2000 13:09:01 +1300
bryce@albatross.co.nz wrote:
> The following example is illegal because 'r' may not have
> been assigned when it is concatenated. gcj does not pick
> up this error.
Here's another similar situation where gcj fails to report a
lack-of-definate-assignment error:
public class DefinateAssign
{
DefinateAssign next;
public Object a()
{
DefinateAssign e;
if (next != null)
e = next;
if (e == null)
{
e = new DefinateAssign();
}
return e;
}
}
In this case "e" can end up being a garbage pointer, which will cause
weird crashes elsewhere. I got tripped up by this badly, guess I
should have tried to compile with jikes ;-)
[ bryce ]