This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/17352] New: Uninitialized char variable causes erratic behavior
- From: "dtiller at captechventures dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Sep 2004 18:35:51 -0000
- Subject: [Bug java/17352] New: Uninitialized char variable causes erratic behavior
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I am using gcj-3.4.1 to compile crimson-1.1.3.jar to a static object file. When
I leave a particular Java char variable uninitialized, String and char
operations return garbage. If I initialize the variable with a throwaway value,
the program runs as expected.
In order to reproduce this issue:
1) Download crimson-1.1.3 source from <a
href="http://xml.apache.org/dist/crimson/crimson-1.1.3-src.tar.gz">here</a> or
download the attached copy. Use the ant build script to create crimson.jar.
2) compile it to an object file anf then static library with:
gcj -c -o crimson.o crimson.jar
ar r libcrimson.a crimson.o
ranlib libcrimson.a
3) Compile and link the test program:
gcj -o Test Test.java -Icrimson.jar -L. -lcrimson -static --main=Test
4) Execute the program. You may have to set the environment variable
LANG="en_US" to avoid bug #13708. This run will result in an Exception
complaining about a bad XML version number.
5) Change line 848 in org.apache.crimson.parser.Parser2.java to "char c = 'X';"
and perform steps 1-4 again. This time the test program will succeed.
test.xml:
-----CUT HERE-----
<?xml version="1.0" encoding="UTF-8" ?>
<test />
-----CUT HERE-----
Test.java:
-----CUT HERE-----
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.io.FileInputStream;
class Test {
public static void main(String[] args) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setNamespaceAware(true);
dbf.setCoalescing(true);
DocumentBuilder db = dbf.newDocumentBuilder();
FileInputStream fis = new FileInputStream("test.xml");
db.parse(fis);
} catch (Exception e) {
System.err.println("Caught " + e);
e.printStackTrace();
}
}
}
-----CUT HERE-----
--
Summary: Uninitialized char variable causes erratic behavior
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dtiller at captechventures dot com
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17352