public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/25001] New: dos equis
@ 2005-11-23 14:07 vadimn at redhat dot com
2005-11-23 14:12 ` [Bug java/25001] " vadimn at redhat dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vadimn at redhat dot com @ 2005-11-23 14:07 UTC (permalink / raw)
To: java-prs
GCJ produces incorrect byte- and native code for a variation of
2-expressive-puzzlers/puzzle-8/DosEquis.java
from
http://www.javapuzzlers.com/java-puzzlers.zip
Specifically,
| $ cat DosEquis.java
| public class DosEquis {
| public static void main(String[] _) {
| char x = 'X';
| final int i = 0;
| System.out.print (true ? x : 0);
| System.out.println(false ? i : x);
| }
| }
This should print out XX, as it does under Sun's JVM:
| $ java -version
| java version "1.4.2_08"
| Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
| Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
| $ javac DosEquis.java
| $ java -cp . DosEquis
| XX
Under GCJ, I get X88 instead:
| $ gcj --version
| gcj (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5)
| Copyright (C) 2005 Free Software Foundation, Inc.
| This is free software; see the source for copying conditions. There is NO
| warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| $ gcj -C DosEquis.java
| $ gij DosEquis
| X88
| $ gcj -o dos-equis --main=DosEquis DosEquis.java
| $ ./dos-equis
| X88
Eclipse compiler gets it right:
| $ rm DosEquis.class
| $ ecj -v
| Eclipse Java Compiler v_579_R31x, 3.1.1 release, Copyright IBM Corp \
| 2000, 2005. All rights reserved.
| $ ecj DosEquis.java
| $ gij DosEquis
| XX
GCJ violates the following JLS clause:
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#290293
| 15.25 Conditional Operator ? :
|
| The type of a conditional expression is determined as follows:
|
| * If one of the operands is of type T where T is byte, short, or
| char, and the other operand is a constant expression of type int
| whose value is representable in type T, then the type of the
| conditional expression is T.
Since i is declared final in the above example, it is a constant
expression of type int. Therefore, the above clause applies in this
case.
--
Summary: dos equis
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: vadimn at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25001
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug java/25001] dos equis
2005-11-23 14:07 [Bug java/25001] New: dos equis vadimn at redhat dot com
@ 2005-11-23 14:12 ` vadimn at redhat dot com
2005-11-24 9:33 ` rmathew at gcc dot gnu dot org
2007-01-09 20:52 ` tromey at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: vadimn at redhat dot com @ 2005-11-23 14:12 UTC (permalink / raw)
To: java-prs
------- Comment #1 from vadimn at redhat dot com 2005-11-23 14:12 -------
> Since i is declared final in the above example, it is a constant
> expression of type int. Therefore, the above clause applies in this
> case.
See also
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5313
| 15.28 Constant Expression
|
| A compile-time constant expression is an expression denoting a
| value of primitive type or a String that is composed using only
| the following:
|
| [...]
|
| * Simple names that refer to final variables whose initializers
| are constant expressions
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25001
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug java/25001] dos equis
2005-11-23 14:07 [Bug java/25001] New: dos equis vadimn at redhat dot com
2005-11-23 14:12 ` [Bug java/25001] " vadimn at redhat dot com
@ 2005-11-24 9:33 ` rmathew at gcc dot gnu dot org
2007-01-09 20:52 ` tromey at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: rmathew at gcc dot gnu dot org @ 2005-11-24 9:33 UTC (permalink / raw)
To: java-prs
------- Comment #2 from rmathew at gcc dot gnu dot org 2005-11-24 09:33 -------
Confirmed on mainline. Also confirmed that GCJX does not have this bug.
--
rmathew at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-11-24 09:33:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25001
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug java/25001] dos equis
2005-11-23 14:07 [Bug java/25001] New: dos equis vadimn at redhat dot com
2005-11-23 14:12 ` [Bug java/25001] " vadimn at redhat dot com
2005-11-24 9:33 ` rmathew at gcc dot gnu dot org
@ 2007-01-09 20:52 ` tromey at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-01-09 20:52 UTC (permalink / raw)
To: java-prs
------- Comment #3 from tromey at gcc dot gnu dot org 2007-01-09 20:48 -------
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.
--
tromey at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25001
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-09 20:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23 14:07 [Bug java/25001] New: dos equis vadimn at redhat dot com
2005-11-23 14:12 ` [Bug java/25001] " vadimn at redhat dot com
2005-11-24 9:33 ` rmathew at gcc dot gnu dot org
2007-01-09 20:52 ` tromey at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).