From 09f6d778407d16cdf99b7c78b4386c2b3c415a76 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 21 Dec 2018 21:41:31 +0000 Subject: [PATCH] Fix `static_assert()` scope in `SizeClassAllocator32`. It should be at the class scope and not inside the `Init(...)` function because we want to error out as soon as the wrong type is constructed. At the function scope the `static_assert` is only checked if the function might be called. This is a follow up to r349138. rdar://problem/45284065 llvm-svn: 349959 --- compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h index e5d6376..abaac3d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -57,6 +57,10 @@ class SizeClassAllocator32 { typedef typename Params::ByteMap ByteMap; typedef typename Params::MapUnmapCallback MapUnmapCallback; + static_assert( + is_same::value, + "AddressSpaceView type mismatch"); + static const bool kRandomShuffleChunks = Params::kFlags & SizeClassAllocator32FlagMasks::kRandomShuffleChunks; static const bool kUseSeparateSizeClassForBatch = Params::kFlags & @@ -109,9 +113,6 @@ class SizeClassAllocator32 { typedef SizeClassAllocator32LocalCache AllocatorCache; void Init(s32 release_to_os_interval_ms) { - static_assert( - is_same::value, - "AddressSpaceView type mismatch"); possible_regions.Init(); internal_memset(size_class_info_array, 0, sizeof(size_class_info_array)); } -- 2.7.4