Avoid negation of signed integers in C that may hold INT*_MIN.
Reported by minoki. Recent C compilers 'take advantage' of the undefined behavior. This completely changes the meaning of expressions like (k == -k).
This commit is contained in:
@@ -327,7 +327,7 @@ typedef struct GCproto {
|
||||
#define PROTO_UV_IMMUTABLE 0x4000 /* Immutable upvalue. */
|
||||
|
||||
#define proto_kgc(pt, idx) \
|
||||
check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \
|
||||
check_exp((uintptr_t)(intptr_t)(idx) >= ~(uintptr_t)(pt)->sizekgc+1u, \
|
||||
gcref(mref((pt)->k, GCRef)[(idx)]))
|
||||
#define proto_knumtv(pt, idx) \
|
||||
check_exp((uintptr_t)(idx) < (pt)->sizekn, &mref((pt)->k, TValue)[(idx)])
|
||||
|
||||
Reference in New Issue
Block a user