Files
allwpilib/upstream_utils/llvm_patches/0035-Fix-minIntN-and-maxIntN-assertions.patch
PJ Reiniger 32cd2ddf8e [upstream_utils] Remove patch that results in building with NDEBUG causing ODR issues (#8539)
Semiwrap / meson / robotpy define `NDEBUG` when building their software
in all modes, while `allwplib` only does it when building debug. This
causes the size of `DenseMap` to differ between the shared libraries
built here, and the extension modules built in `mostrobotpy`, causing
segfaults when you try to execute code that uses `DenseMap`. This is not
a problem with the robotpy code in `allwpilib`, because bazel uses the
exact same compiler flags when building the shared libraries and
pybind11 extensions.
2026-01-03 13:32:16 -08:00

32 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Mon, 23 Dec 2024 22:56:29 -0800
Subject: [PATCH 35/35] Fix minIntN() and maxIntN() assertions
---
llvm/include/llvm/Support/MathExtras.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index 5191831247ff668f22b6015d5b135fd9701afdd2..5b2dccf8959856f2c6dbf3cc4d5260d1ad541459 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -203,7 +203,7 @@ inline uint64_t maxUIntN(uint64_t N) {
/// Gets the minimum value for a N-bit signed integer.
inline int64_t minIntN(int64_t N) {
- assert(N <= 64 && "integer width out of range");
+ assert(N >= 0 && N <= 64 && "integer width out of range");
if (N == 0)
return 0;
@@ -216,7 +216,7 @@ inline int64_t minIntN(int64_t N) {
/// Gets the maximum value for a N-bit signed integer.
inline int64_t maxIntN(int64_t N) {
- assert(N <= 64 && "integer width out of range");
+ assert(N >= 0 && N <= 64 && "integer width out of range");
// This relies on two's complement wraparound when N == 64, so we convert to
// int64_t only at the very end to avoid UB.