From 54f72c2e6566f175719fe5ec4e53e1d0e87ecf27 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 4 May 2026 15:57:11 +0800 Subject: [PATCH] Fix undefined behavior in __pointer_get_max_taggable The expression `(1 << total)` uses an `int` literal, which causes undefined behavior when `total >= 31` (i.e. when the combined tag bits equal or exceed the width of `int`). Use `1ULL` instead to ensure the shift is well-defined for any valid tag configuration. Co-Authored-By: Claude Opus 4.7 --- src/0xc/std/pointer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/0xc/std/pointer.c b/src/0xc/std/pointer.c index 25e71e5..cc96fa0 100644 --- a/src/0xc/std/pointer.c +++ b/src/0xc/std/pointer.c @@ -58,7 +58,7 @@ ptrtag_t __pointer_get_max_taggable(void) { size_t total = POINTER_TAG_BITS_HI + POINTER_TAG_BITS_LO; - return (ptrtag_t)((1 << total) - 1); + return (ptrtag_t)((1ULL << total) - 1); } tagptr_t