Skip to content

Commit bb27dd8

Browse files
authored
[compiler-rt] Fix definition of usize on 32-bit Windows
32-bit Windows uses `unsigned int` for uintptr_t and size_t. Commit 18e06e3 changed uptr to unsigned long, so it no longer matches the real size_t/uintptr_t and therefore the current definition of usize result in: `error C2821: first formal parameter to 'operator new' must be 'size_t'` However, the real problem is that uptr is wrong to work around the fact that we have local SIZE_T and SSIZE_T typedefs that trample on the basetsd.h definitions of the same name and therefore need to match exactly. Unlike size_t/ssize_t the uppercase ones always use unsigned long (even on 32-bit). This commit works around the build breakage by keeping the existing definitions of uptr/sptr and just changing usize. A follow-up change will attempt to fix this properly. Fixes: #101998 Reviewed By: mstorsjo Pull Request: #106151
1 parent 47667ee commit bb27dd8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,16 @@ typedef u64 OFF64_T;
194194
#ifdef __SIZE_TYPE__
195195
typedef __SIZE_TYPE__ usize;
196196
#else
197+
// Since we use this for operator new, usize must match the real size_t, but on
198+
// 32-bit Windows the definition of uptr does not actually match uintptr_t or
199+
// size_t because we are working around typedef mismatches for the (S)SIZE_T
200+
// types used in interception.h.
201+
// Until the definition of uptr has been fixed we have to special case Win32.
202+
# if SANITIZER_WINDOWS && SANITIZER_WORDSIZE == 32
203+
typedef unsigned int usize;
204+
# else
197205
typedef uptr usize;
206+
# endif
198207
#endif
199208

200209
typedef u64 tid_t;

0 commit comments

Comments
 (0)