[clang] 2529fc4 - [CIR] [Fix] W64 Compiler error for std::max (#174519)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 6 10:09:59 PST 2026
Author: DannyDaoBoYang
Date: 2026-01-06T18:09:54Z
New Revision: 2529fc4467cdaf58196c779a6234ebea7c047257
URL: https://github.com/llvm/llvm-project/commit/2529fc4467cdaf58196c779a6234ebea7c047257
DIFF: https://github.com/llvm/llvm-project/commit/2529fc4467cdaf58196c779a6234ebea7c047257.diff
LOG: [CIR] [Fix] W64 Compiler error for std::max (#174519)
In W64, size_t and ul are different sizes. So, std::max cannot correctly
deduce the operator type, resulting an error at compile time.
The fix was originally added in
https://github.com/llvm/llvm-project/pull/173802, but as suggested it's
best to keep unrelated changes separate.
Added:
Modified:
clang/lib/CIR/CodeGen/CIRGenCleanup.cpp
Removed:
################################################################################
diff --git a/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp b/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp
index 6c6cb402d1190..8d9ea7c6c22eb 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCleanup.cpp
@@ -97,7 +97,7 @@ EHScopeStack::getInnermostActiveNormalCleanup() const {
char *EHScopeStack::allocate(size_t size) {
size = llvm::alignTo(size, ScopeStackAlignment);
if (!startOfBuffer) {
- unsigned capacity = llvm::PowerOf2Ceil(std::max(size, 1024ul));
+ unsigned capacity = llvm::PowerOf2Ceil(std::max<size_t>(size, 1024ul));
startOfBuffer = std::make_unique<char[]>(capacity);
startOfData = endOfBuffer = startOfBuffer.get() + capacity;
} else if (static_cast<size_t>(startOfData - startOfBuffer.get()) < size) {
More information about the cfe-commits
mailing list