User account creation filtered due to spam.

Bug 44109 - gcj handling of assertions is in conflict with documentation
Summary: gcj handling of assertions is in conflict with documentation
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2010-05-13 11:13 UTC by Peter Keller
Modified: 2016-09-30 22:51 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:

Output from compile/link step of test program (1.18 KB, text/plain)
2010-05-13 11:14 UTC, Peter Keller
Preprocessor output from compiling test program (165 bytes, text/plain)
2010-05-13 11:15 UTC, Peter Keller

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Keller 2010-05-13 11:13:32 UTC
Built/installed gcc under openSUSE 11.1 with:

../configure --prefix=$pre --enable-languages=c,java

Test program

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

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

 ./a.out; echo $?


Exception in thread "main" java.lang.AssertionError: test assertion
   at AssertionTest.main(a.out)


Hello World!

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

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?
Comment 1 Peter Keller 2010-05-13 11:14:34 UTC
Created attachment 20656 [details]
Output from compile/link step of test program
Comment 2 Peter Keller 2010-05-13 11:15:43 UTC
Created attachment 20657 [details]
Preprocessor output from compiling test program
Comment 3 Andrew Pinski 2016-09-30 22:51:12 UTC
Closing as won't fix as the Java front-end has been removed from the trunk.