http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60667
Bug ID: 60667 Summary: Undefined behavior in Java FE Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: java Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: aph at gcc dot gnu.org Undefined behavior in java FE. In --with-build-config=bootstrap-ubsan i686 trunk bootstrap I'm getting several: ../../gcc/double-int.c:1064:33: runtime error: shift exponent -65 is negative errors (and similar), e.g. on: /usr/src/gcc/obj985a/./gcc/gcj -B/usr/src/gcc/obj985a/i686-pc-linux-gnu/libjava/ -B/usr/src/gcc/obj985a/./gcc/ -B/usr/local/i686-pc-linux-gnu/bin/ -B/usr/local/i686-pc-linux-gnu/lib/ -isystem /usr/local/i686-pc-linux-gnu/include -isystem /usr/local/i686-pc-linux-gnu/sys-include -ffloat-store -fomit-frame-pointer -Usun -fclasspath= -fbootclasspath=../../../libjava/classpath/lib --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -c -fsource-filename=/usr/src/gcc/obj985a/i686-pc-linux-gnu/libjava/classpath/lib/classes -MT gnu/java/awt.lo -MD -MP -MF gnu/java/awt.deps @gnu/java/awt.list -fPIC -o gnu/java/.libs/awt.o This happens on: #0 double_int::set_bit (this=0xffffc920, bitpos=4294967295) at ../../gcc/double-int.c:1064 #1 0x08258b8a in mark_reference_fields (field=0xf79c1844, mask=<optimized out>, pointer_after_end=0xffffc920, all_bits_set=0x8258e06, last_set_index=0xffffc90c, last_view_index=0xffffc910, ubit=32) at ../../gcc/java/boehm.c:110 p int_byte_position (field) $12 = 128 p ubit $13 = 32 p int_size_in_bytes (field->typed.type) $17 = 4 Thus count is 32, ubit 32, size_words 1 and ubit - count - i - 1 is -1, thus *mask = (*mask).set_bit (ubit - count - i - 1); is set_bit (0xffffffff) and attempts to shift up by (int) (0xffffffff - 64). p debug_tree (field) <field_decl 0xf79c1844 focusListener type <pointer_type 0xf79b1c00 type <record_type 0xf79b1ba0 java.awt.event.FocusListener type_2 type_4 SI size <integer_cst 0xf78e3540 constant 32> unit size <integer_cst 0xf78e3e54 constant 4> align 32 symtab 0 alias set -1 canonical type 0xf79b1ba0 fields <field_decl 0xf7a0c958 D.1856> pointer_to_this <pointer_type 0xf79b1c00> chain <type_decl 0xf79a5ca8 java.awt.event.FocusListener>> unsigned SI size <integer_cst 0xf78e3540 32> unit size <integer_cst 0xf78e355c constant 4> align 32 symtab 0 alias set -1 canonical type 0xf79b1c00 pointer_to_this <pointer_type 0xf79b1d80>> unsigned decl_5 SI file /usr/src/gcc/libjava/classpath/java/awt/Component.java line 0 col 0 size <integer_cst 0xf78e3540 32> unit size <integer_cst 0xf78e355c 4> align 32 offset_align 128 offset <integer_cst 0xf78fe1c0 type <integer_type 0xf78f4000 sizetype> constant 128> bit offset <integer_cst 0xf78e35e8 type <integer_type 0xf78f4060 bitsizetype> constant 0> context <record_type 0xf7908720 java.awt.Component> chain <field_decl 0xf79c18a0 keyListener>> $18 = void Can you please fix this, I have no idea what this code tries to do and why.