aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2012-04-16 01:13:25 +0200
committerMichael Matz <matz@suse.de>2012-04-18 20:57:14 +0200
commit718fd591fa93ff254a9ca68a0ad2ff8a55756489 (patch)
tree69ef5bb9cdfa3673317df44c8ba402526e758ef8 /libtcc.c
parentb068e29df753192bdcec5b1e41401bdc21812136 (diff)
downloadtinycc-718fd591fa93ff254a9ca68a0ad2ff8a55756489.tar.gz
tinycc-718fd591fa93ff254a9ca68a0ad2ff8a55756489.tar.bz2
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).
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c6
1 files changed, 6 insertions, 0 deletions
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);