This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gas: microblaze: fix shift overflow
- From: Michael Eager <eager at eagerm dot com>
- To: Mike Frysinger <vapier at gentoo dot org>, binutils at sourceware dot org
- Date: Mon, 16 Nov 2015 08:21:48 -0800
- Subject: Re: [PATCH] gas: microblaze: fix shift overflow
- Authentication-results: sourceware.org; auth=none
- References: <1447573743-30866-1-git-send-email-vapier at gentoo dot org>
On 11/14/2015 11:49 PM, Mike Frysinger wrote:
This code tries to shift an integer 31 bits which triggers a werror:
gas/config/tc-microblaze.c:742:21: error: integer overflow in expression [-Werror=overflow]
e->X_add_number |= -(1 << 31);
Cast the 1 to offsetT to match X_add_number to fix things.
2015-11-15 Mike Frysinger <vapier@gentoo.org>
* config/tc-microblaze.c (parse_imm): Add an offsetT cast.
---
gas/config/tc-microblaze.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index ac7c828..0ec24f8 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -739,7 +739,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
{
/* Special case: sign extend negative 32-bit values to 64-bits. */
if ((e->X_add_number >> 31) == 1)
- e->X_add_number |= -(1 << 31);
+ e->X_add_number |= -((offsetT) 1 << 31);
if (e->X_add_number < min || e->X_add_number > max)
{
OK.
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077