java/4022: ?: precedence is wrong.
apbianco@redhat.com
apbianco@redhat.com
Tue Aug 14 12:46:00 GMT 2001
>Number: 4022
>Category: java
>Synopsis: ?: precedence is wrong.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 14 12:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Alex Petit-Bianco
>Release: 3.0 and trunk.
>Organization:
>Environment:
Most likely all. x86/linux definitively.
>Description:
Consider this test case:
public class Test {
public static void main(String[] args) {
String s = null;
System.out.println("foo" + s != null ? s : "");
}
}
$ ./test
null
When enclosed in parentheses, it behaves normally:
System.out.println("foo" + (s != null ? s : ""));
$ ./test
foo
A core dump happens when this is done in a toString method:
public class Test {
public static void main(String[] args) {
System.out.println(new Test());
}
public String toString() {
String s = null;
return "foo" + s != null ? s : "";
}
}
>How-To-Repeat:
Build the examples above.
>Fix:
Not yet.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="null"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="null"
More information about the Gcc-bugs
mailing list