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