Sign extension of type with precision of 0 causes fault in force_fit_type
John David Anglin
dave@hiauly1.hia.nrc.ca
Tue Apr 10 15:40:00 GMT 2001
> The fault occurs in force_fit_type in fold-const.c. This code causes
> the problem when prec has the value 0:
>
> /* If the value's sign bit is set, extend the sign. */
> if (prec != 2 * HOST_BITS_PER_WIDE_INT
> && (prec > HOST_BITS_PER_WIDE_INT
> ? 0 != (TREE_INT_CST_HIGH (t)
> & ((HOST_WIDE_INT) 1
> << (prec - HOST_BITS_PER_WIDE_INT - 1)))
> : 0 != (TREE_INT_CST_LOW (t)
> & ((unsigned HOST_WIDE_INT) 1 << (prec - 1)))))
> {
Here is a bit more information on how the fault occurs:
(gdb) bt
#0 force_fit_type (t=0x232100, overflow=0) at ../../gcc/fold-const.c:203
#1 0xb7968 in size_int_type_wide (number=6432, type=0x22f670)
at ../../gcc/fold-const.c:1896
#2 0xb7190 in int_const_binop (code=MULT_EXPR, arg1=0x232060, arg2=0x22f820,
notrunc=0, forsize=1) at ../../gcc/fold-const.c:1614
#3 0xb7a42 in size_binop (code=MULT_EXPR, arg0=0x232060, arg1=0x22f820)
at ../../gcc/fold-const.c:1929
#4 0xc079e in round_up (value=0x2320c0, divisor=32)
at ../../gcc/stor-layout.c:273
#5 0xc1905 in finalize_type_size (type=0x232468)
at ../../gcc/stor-layout.c:1167
#6 0xc1a9f in layout_type (type=0x232468) at ../../gcc/stor-layout.c:1525
#7 0xa9318 in type_hash_lookup (hashcode=389552, type=0x232468)
at ../../gcc/tree.c:3120
#8 0xa938d in type_hash_canon (hashcode=389552, type=0x232468)
at ../../gcc/tree.c:3173
#9 0xa9e66 in build_array_type (elt_type=0x22d740, index_type=0x231a70)
at ../../gcc/tree.c:3860
#10 0x90571 in c_common_nodes_and_builtins () at ../../gcc/c-common.c:2848
#11 0x10a22 in init_decl_processing () at ../../gcc/cp/decl.c:6391
#12 0xa1f1d in compile_file (name=0x7fffc1fa "prec.cc")
at ../../gcc/toplev.c:2197
#13 0xa5953 in main (argc=3, argv=0x7fffc12c, 2147467580)
(gdb) frame 0
#0 force_fit_type (t=0x232100, overflow=0) at ../../gcc/fold-const.c:203
203 if (POINTER_TYPE_P (TREE_TYPE (t)))
(gdb) p debug_tree (t)
<integer_cst 00232100 type <integer_type 0022f670 bit_size_type> constant 6432>
(gdb) frame 1
#1 0xb7968 in size_int_type_wide (number=6432, type=0x22f670)
at ../../gcc/fold-const.c:1896
1896 TREE_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (t) = force_fit_type (t, 0);
(gdb) p debug_tree (type)
<integer_type 0022f670 bit_size_type unsigned sizetype DI
size <integer_cst 0022dfe0 type <integer_type 0022f670 bit_size_type> constant 64>
unit size <integer_cst 0022f800 type <integer_type 0022f608 unsigned int> constant 8>
align 32 symtab 0 alias set -1 precision 36 min <integer_cst 0022dfa0 0> max <integer_cst 0022dfc0 0xfffffffff>>
I don't see where TYPE_PRECISION (t) gets set.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
More information about the Gcc-bugs
mailing list