This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Avoid GCC shift overflow warning


Andrew Cagney wrote:
> 
> FYI,
> 
> I've committed the attatched.  GCC was still convinced that the shift
> would overflow.

Oooh, that's really weird.  Have you reported this as a GCC bug?

> 
>         Andrew
> 
>     ---------------------------------------------------------------
> Tue Apr  4 12:13:19 2000  Andrew Cagney  <cagney@b1.cygnus.com>
> 
>         * printcmd.c (print_scalar_formatted): Use local variable ptr_bit
>         in shift.  Stop GCC thinking it has a shift overflow.
> 
> Index: printcmd.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/printcmd.c,v
> retrieving revision 1.2
> diff -p -r1.2 printcmd.c
> *** printcmd.c  2000/03/22 20:55:15     1.2
> --- printcmd.c  2000/04/04 04:11:46
> *************** print_scalar_formatted (valaddr, type, f
> *** 445,454 ****
>       case 'a':
>         {
>         /* Truncate address to the size of a target pointer, avoiding
> !          shifts larger or equal than the width of a CORE_ADDR.  */
>         CORE_ADDR addr = unpack_pointer (type, valaddr);
> !       if (TARGET_PTR_BIT < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
> !         addr &= ((CORE_ADDR) 1 << TARGET_PTR_BIT) - 1;
>         print_address (addr, stream);
>         }
>         break;
> --- 445,457 ----
>       case 'a':
>         {
>         /* Truncate address to the size of a target pointer, avoiding
> !          shifts larger or equal than the width of a CORE_ADDR.  The
> !          local variable PTR_BIT stops the compiler reporting a shift
> !          overflow when it won't occure. */
>         CORE_ADDR addr = unpack_pointer (type, valaddr);
> !       int ptr_bit = TARGET_PTR_BIT;
> !       if (ptr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
> !         addr &= ((CORE_ADDR) 1 << ptr_bit) - 1;
>         print_address (addr, stream);
>         }
>         break;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]