This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [PATCH 0/2] Fix invalid left shift of negative value.


On Tue, 10 Nov 2015 12:16:38 +0100
Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:

> The following series of patches fixes all occurences of
> left-shifting negative constants in C code which is undefined by
> the C standard.  The patches have been tested on s390x, covering
> only a small subset of the changes.

Looking at one of your changes from part 1/2...

-    (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+    -((LONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1));

What aspect of the original expression is not defined by the C standard?

(I'm looking at an old copy of Harbison & Steel; the original expression
looks okay to me, but perhaps I'm missing something...)

FWIW, I have an easier time understanding the intent of the first/original
expression than your proposed replacement.

Kevin


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