This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug java/44109] New: gcj handling of assertions is in conflict with documentation
- From: "pkeller at globalphasing dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 13 May 2010 11:13:33 -0000
- Subject: [Bug java/44109] New: gcj handling of assertions is in conflict with documentation
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Built/installed gcc under openSUSE 11.1 with:
../configure --prefix=$pre --enable-languages=c,java
Test program AssertionTest.java:
class AssertionTest {
static public void main( String args[] ) {
assert false: "test assertion";
System.out.println("Hello World!");
}
}
Compile/link as follows:
$pre/bin/gcj -v -save-temps --disable-assertions -Wl,-rpath,$pre/lib64
--main=AssertionTest AssertionTest.java
Output in AssertionTest.out. Note in particular the line:
cc1: warning: command line option "-fdisable-assertions" is valid for Java but
not for C
which is also output when not using the -v option.
According to the documentation from 'man -M $pre/share/man gcj', the
--disable-assertions option should exclude assertion checks from the
compiled code, but this does not appear to happen. Running the binary
as:
./a.out; echo $?
gives:
Exception in thread "main" java.lang.AssertionError: test assertion
at AssertionTest.main(a.out)
1
Expected:
Hello World!
0
Also, from man -M $pre/share/man gcj
By default, assertions are enabled when generating class files or when not
optimizing, and disabled when generating optimized binaries.
However, generating an optimized binary as follows:
$pre/bin/gcj -O -Wl,-rpath,$pre/lib64 --main=AssertionTest AssertionTest.java
succeeds without errors or warnings, but assertions are not
disabled. "./a.out; echo $?" gives the same result as above.
>From a cursory look at some older versions of gcc, it appears that
this is long-standing behaviour. If it is intentional, maybe this is
merely a documentation bug?
--
Summary: gcj handling of assertions is in conflict with
documentation
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pkeller at globalphasing dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44109