[Allocator] Cap MinAlign at alignof(max_align_t) (#235373)

alignof(std::max_align_t) is 4 on NetBSD/i386, whose <stddef.h> defines
max_align_t as a union of void *, long double, and long long.

Fix #230782

(cherry picked from commit 0b6b6ed806536c1b170101061ff3eeed91c8f061)
This commit is contained in:
Fangrui Song authored and Douglas Yung committed 2026-10-27 19:03:38 +00:00
1 parent 8ceacf8097
commit ecf9bb207c
1 file changed
+1 -1
+1 -1
View File
@@ -64,7 +64,7 @@ LLVM_ABI void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t TotalMemory);
/// CurPtr when the requested alignment is no greater than MinAlign.
template <typename AllocatorT = MallocAllocator, size_t SlabSize = 4096,
size_t SizeThreshold = SlabSize, size_t GrowthDelay = 128,
size_t MinAlign = 8>
size_t MinAlign = std::min<size_t>(8, alignof(std::max_align_t))>
class BumpPtrAllocatorImpl
: public AllocatorBase<BumpPtrAllocatorImpl<
AllocatorT, SlabSize, SizeThreshold, GrowthDelay, MinAlign>>,