This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH 0/2] Fix invalid left shift of negative value.
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 10 Nov 2015 15:42:43 -0700
- Subject: Re: [PATCH 0/2] Fix invalid left shift of negative value.
- Authentication-results: sourceware.org; auth=none
- References: <20151110111638 dot GD17214 at linux dot vnet dot ibm dot com>
On Tue, 10 Nov 2015 12:16:38 +0100
Dominik Vogt <email@example.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.