on master help sign in
Fix negative number literal warning

By casting, because we're really shifting the bit pattern, not the number itself

commit4c0acf676dc5dd4eb1655b727e1818fa19550311 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 31 Mar 2017, 14:15 (10 years ago) parent4a6974c
1 file changed+3−1
rts/idris_rts.h+3−1
rts/idris_rts.h+3−1
@@ -213,7 +213,9 @@ typedef void(*func)(VM*, VAL*);
213213
214214typedef intptr_t i_int;
215215
216−#define MKINT(x) ((void*)((i_int)(((x)<<1)+1)))
216+// Shifting a negative number left is undefined and (rightly) gives a warning,
217+// but we're only interested in shifting the bit pattern, so cast it
218+#define MKINT(x) ((void*)((i_int)((((uintptr_t)x)<<1)+1)))
217219#define GETINT(x) ((i_int)(x)>>1)
218220#define ISINT(x) ((((i_int)x)&1) == 1)
219221#define ISSTR(x) (GETTY(x) == CT_STRING)