Avoid shifting into sign bit

It's undefined behavior.  Found with gcc -fsanitize=undefined.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-07-26 18:00:27 +02:00
parent d58bea5458
commit b9375b14b1
2 changed files with 2 additions and 2 deletions

View file

@ -52,7 +52,7 @@
#endif #endif
#ifndef bit #ifndef bit
#define bit(x) (1<<(x)) #define bit(x) (1U<<(x))
#endif #endif
#define minutes(x) (60*(x)) #define minutes(x) (60*(x))

View file

@ -97,7 +97,7 @@ verify_tabref(int type, int row, struct castr *ca, int idx, long val)
if (CANT_HAPPEN(ca_sym != symbol_ca)) if (CANT_HAPPEN(ca_sym != symbol_ca))
return -1; return -1;
for (i = 0; i < (int)sizeof(long) * 8; i++) { for (i = 0; i < (int)sizeof(long) * 8; i++) {
if (val & (1L << i)) { if (val & (1UL << i)) {
if (!symbol_by_value(1L << i, ef_ptr(tabno, 0))) { if (!symbol_by_value(1L << i, ef_ptr(tabno, 0))) {
verify_fail(type, row, ca, idx, verify_fail(type, row, ca, idx,
"bit %d is not in symbol table %s", "bit %d is not in symbol table %s",