From 718fd591fa93ff254a9ca68a0ad2ff8a55756489 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 16 Apr 2012 01:13:25 +0200 Subject: Make sizeof() be of type size_t This matters when sizeof is directly used in arithmetic, ala "uintptr_t t; t &= -sizeof(long)" (for alignment). When sizeof isn't size_t (as it's specified to be) this masking will truncate the high bits of the uintptr_t object (if uintptr_t is larger than uint). --- libtcc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libtcc.c') diff --git a/libtcc.c b/libtcc.c index c6b8d38..01280de 100644 --- a/libtcc.c +++ b/libtcc.c @@ -745,6 +745,12 @@ static int tcc_compile(TCCState *s1) char_pointer_type.t = VT_BYTE; mk_pointer(&char_pointer_type); +#if PTR_SIZE == 4 + size_type.t = VT_INT; +#else + size_type.t = VT_LLONG; +#endif + func_old_type.t = VT_FUNC; func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD); -- cgit v1.3.1