[Bug java/16927] New: assert statement fails at -O1 and above

fw at deneb dot enyo dot de gcc-bugzilla@gcc.gnu.org
Mon Aug 9 05:23:00 GMT 2004


The following class cannot be compiled at optimization levels -O1 and above:

public class AssertBug {
    public void bug(Integer i) {
        assert(i.intValue() == 0):
            i.toString() + "!";
    }
}

/tmp/AssertBug.java: In class `AssertBug':
/tmp/AssertBug.java: In method `AssertBug.bug(java.lang.Integer)':
/tmp/AssertBug.java:3: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The crash occurs at /home/fw/src/gnu/gcc/gcc/java/check-init.c:879:
874         case EXPR_WITH_FILE_LOCATION:
875           {
876             location_t saved_location = input_location;
877             tree saved_wfl = wfl;
878             tree body = EXPR_WFL_NODE (exp);
879             if (IS_EMPTY_STMT (body))
880               break;
881             wfl = exp;
882             input_filename = EXPR_WFL_FILENAME (exp);
883             input_line = EXPR_WFL_LINENO (exp);

The tree at exp seems to look like this:

 <expr_with_file_location 0x403e2528 side-effects tree_2 tree_5
    arg 1 <identifier_node 0x4037b118 /tmp/AssertBug.java tree_4 tree_5>
    arg 2 <tree_list 0x403db5a0
        purpose <new_class_expr 0x403e24d8 side-effects
            arg 0 <expr_with_file_location 0x4037c258
                arg 0 <identifier_node 0x4037c230 gnu.gcj.runtime.StringBuffer
tree_2>>>
        chain <tree_list 0x403db5b8
            purpose <call_expr 0x403e2500 side-effects
                arg 0 <expr_with_file_location 0x4037c208
                    arg 0 <identifier_node 0x4037c1e0 append>>
                arg 1 <tree_list 0x403db588
                    value <compound_expr 0x40329480 type <pointer_type 0x403313a0>
                        side-effects tree_6
                        arg 0 <cond_expr 0x403e2460 type <pointer_type 0x4037e0e8>
                            side-effects arg 0 <eq_expr 0x40329438> arg 1
<call_expr 0x403e2438> arg 2 <save_expr 0x403c88e0>>
                        arg 1 <save_expr 0x403c8980 type <pointer_type 0x403313a0>
                            side-effects readonly invariant arg 0 <compound_expr
0x4032945c>>>>>
            chain <tree_list 0x403db5e8
                purpose <call_expr 0x403e2550 side-effects arg 0
<expr_with_file_location 0x4037c208>
                    arg 1 <tree_list 0x403db5d0
                        value <nop_expr 0x403c89c0 type <pointer_type 0x403313a0>
                            constant invariant arg 0 <array_ref 0x403e1c80>>>>>>>>

-- 
           Summary: assert statement fails at -O1 and above
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fw at deneb dot enyo dot de
                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=16927



More information about the Gcc-bugs mailing list