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).
This commit is contained in:
Michael Matz
2012-04-16 01:13:25 +02:00
parent b068e29df7
commit 718fd591fa
4 changed files with 37 additions and 4 deletions

View File

@ -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);