Sign extension of type with precision of 0 causes fault in force_fit_type
John David Anglin
dave@hiauly1.hia.nrc.ca
Wed Apr 11 17:18: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
The backtrace was wrong. Here is the correct one:
(gdb) bt
#0 0xb5c7f in force_fit_type (t=0x252c20, overflow=0)
at ../../gcc/fold-const.c:247
#1 0xbde70 in fold (expr=0x2525cc) at ../../gcc/fold-const.c:5331
#2 0x8eb09 in min_precision (value=0x23f740, unsignedp=0)
at ../../gcc/c-common.c:1947
#3 0x1c1b1 in finish_enum (enumtype=0x242938) at ../../gcc/cp/decl.c:13004
#4 0x5c950 in yyparse_1 () at /usr/local/share/bison.simple:2240
#5 0x98c44 in yyparse () at ../../gcc/c-lex.c:158
#6 0xa212f in compile_file (name=0x7fffc1fa "prec.cc")
at ../../gcc/toplev.c:2389
#7 0xa5953 in main (argc=3, argv=0x7fffc12c, 2147467580)
at ../../gcc/toplev.c:4959
It appears there is a catch 22 in the above. Finish_enum is attempting
to determine the precision for value, but its precision is needed for
the fold operation.
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