PR26467 UBSAN: cgen.c:762 shift exponent 18446744073709551615

PR 26467
	* cgen.c (weak_operand_overflow_check): Handle opmask for
	operand length zero.  Use 1UL constant.
This commit is contained in:
Alan Modra 2020-08-27 13:46:45 +09:30
parent cd570d497e
commit 6fbd4a8e8b
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2020-08-27 Alan Modra <amodra@gmail.com>
PR 26467
* cgen.c (weak_operand_overflow_check): Handle opmask for
operand length zero. Use 1UL constant.
2020-08-26 Alan Modra <amodra@gmail.com>
PR 26508

View file

@ -759,7 +759,7 @@ weak_operand_overflow_check (const expressionS * exp,
{
const unsigned long len = operand->length;
unsigned long mask;
unsigned long opmask = (((1L << (len - 1)) - 1) << 1) | 1;
unsigned long opmask = len == 0 ? 0 : (1UL << (len - 1) << 1) - 1;
if (!exp)
return NULL;