ref: 9b65a9cadd670f9cdd7ac4d8e203240fbfcd80cf
parent: 58a6c79cc36af196485e291e0d5599f351653a21
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jul 20 04:19:25 EDT 2015
Use uintptr_t for arithmetic on pointers Conversion between pointers and integers are allowed, but the result is implementation defined, except in the case of uinptr_t which is big enough to hold the value of the pointer without losing any information and allow return to the pointer type.
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -210,9 +210,12 @@
unsigned t;
Type *bp;
static char letters[] = {
- [PTR] = L_POINTER, [ARY] = L_ARRAY,
- [FTN] = L_FUNCTION, [ENUM] = L_INT,
- [STRUCT] = L_STRUCT, [UNION] = L_UNION
+ [PTR] = L_POINTER,
+ [ARY] = L_ARRAY,
+ [FTN] = L_FUNCTION,
+ [ENUM] = L_INT,
+ [STRUCT] = L_STRUCT,
+ [UNION] = L_UNION
};
if (op == PTR && tp == voidtype)
@@ -230,7 +233,7 @@
else
type.defined = 1;
- t = (op ^ (char) ((unsigned short) tp >> 3)) & NR_TYPE_HASH-1;
+ t = (op ^ (uintptr_t) tp >> 3) & NR_TYPE_HASH-1;
tbl = &typetab[t];
for (bp = *tbl; bp; bp = bp->next) {
if (eqtype(bp, &type)) {