This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa/pascal!] Gag -Werror shift warning and bug
- To: Pierre Muller <muller at cerbere dot u-strasbg dot fr>,GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: Re: [rfa/pascal!] Gag -Werror shift warning and bug
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Sat, 17 Mar 2001 15:55:56 -0500
- References: <4.2.0.58.20010305095243.00c45b00@ics.u-strasbg.fr>
Pierre Muller wrote:
>
> After looking at the c-exp.y equivalent code, I suggest that you simply
> take that code,
> as it doesn't seem to suffer from the same problems
Good point. I'll check in the attatched.
thanks, Andrew
2001-03-17 Andrew Cagney <ac131313@redhat.com>
* p-exp.y (parse_number): Avoid shift overflow when ``long''.
Code copied from c-exp.y.
*** GDB/src/gdb/p-exp.y Tue Mar 6 10:38:28 2001
--- WIP/src/gdb/p-exp.y Sat Mar 17 15:46:29 2001
***************
*** 858,871 ****
}
else
{
! high_bit = (((ULONGEST)1)
! << (TARGET_LONG_LONG_BIT - 32 - 1)
! << 16
! << 16);
! if (high_bit == 0)
/* A long long does not fit in a LONGEST. */
! high_bit =
! (ULONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
unsigned_type = builtin_type_unsigned_long_long;
signed_type = builtin_type_long_long;
}
--- 858,870 ----
}
else
{
! int shift;
! if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
/* A long long does not fit in a LONGEST. */
! shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
! else
! shift = (TARGET_LONG_LONG_BIT - 1);
! high_bit = (ULONGEST) 1 << shift;
unsigned_type = builtin_type_unsigned_long_long;
signed_type = builtin_type_long_long;
}