[PATCH 0/2] Fix invalid left shift of negative value.
Kevin Buettner
kevinb@redhat.com
Tue Nov 10 22:42:00 GMT 2015
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
More information about the Gdb-patches
mailing list