Skip to content

Commit 357e9c1

Browse files
committed
Fix pretty-printers not working when constexpr variables are optimized away
1 parent 59e2a56 commit 357e9c1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

extra/boost_unordered_printers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Braden Ganetsky
1+
# Copyright 2024-2025 Braden Ganetsky
22
# Distributed under the Boost Software License, Version 1.0.
33
# https://www.boost.org/LICENSE_1_0.txt
44

@@ -191,8 +191,8 @@ def is_sentinel(self, group, pos):
191191
m = group["m"]
192192
at = lambda b: BoostUnorderedHelpers.maybe_unwrap_atomic(m[b]["n"])
193193

194-
N = group["N"]
195-
sentinel_ = group["sentinel_"]
194+
N = 15 # `group["N"]` may be optimized out
195+
sentinel_ = 1 # `group["sentinel_"]` may be optimized out
196196
if self.is_regular_layout(group):
197197
return pos == N-1 and at(N-1) == sentinel_
198198
else:
@@ -234,7 +234,7 @@ def generator():
234234
mask = (self.match_occupied(pc_.cast(groups.type).dereference()) >> (n0+1)) << (n0+1)
235235
while mask == 0:
236236
pc_ = self.cpo.next(pc_, groups.dereference().type.sizeof)
237-
p_ = self.cpo.next(p_, groups.dereference()["N"])
237+
p_ = self.cpo.next(p_, 15) # Use 15 because `groups.dereference()["N"]` may be optimized out
238238
mask = self.match_occupied(pc_.cast(groups.type).dereference())
239239

240240
n = BoostUnorderedHelpers.countr_zero(mask)

include/boost/unordered/unordered_printers.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Copyright 2024 Braden Ganetsky
1+
// Copyright 2024-2025 Braden Ganetsky
22
// Distributed under the Boost Software License, Version 1.0.
33
// https://www.boost.org/LICENSE_1_0.txt
44

5-
// Generated on 2024-08-25T17:48:54
5+
// Generated on 2025-08-08T03:34:52
66

77
#ifndef BOOST_UNORDERED_UNORDERED_PRINTERS_HPP
88
#define BOOST_UNORDERED_UNORDERED_PRINTERS_HPP
@@ -204,8 +204,8 @@ __asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
204204
".ascii \" m = group[\\\"m\\\"]\\n\"\n"
205205
".ascii \" at = lambda b: BoostUnorderedHelpers.maybe_unwrap_atomic(m[b][\\\"n\\\"])\\n\"\n"
206206

207-
".ascii \" N = group[\\\"N\\\"]\\n\"\n"
208-
".ascii \" sentinel_ = group[\\\"sentinel_\\\"]\\n\"\n"
207+
".ascii \" N = 15 # `group[\\\"N\\\"]` may be optimized out\\n\"\n"
208+
".ascii \" sentinel_ = 1 # `group[\\\"sentinel_\\\"]` may be optimized out\\n\"\n"
209209
".ascii \" if self.is_regular_layout(group):\\n\"\n"
210210
".ascii \" return pos == N-1 and at(N-1) == sentinel_\\n\"\n"
211211
".ascii \" else:\\n\"\n"
@@ -247,7 +247,7 @@ __asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
247247
".ascii \" mask = (self.match_occupied(pc_.cast(groups.type).dereference()) >> (n0+1)) << (n0+1)\\n\"\n"
248248
".ascii \" while mask == 0:\\n\"\n"
249249
".ascii \" pc_ = self.cpo.next(pc_, groups.dereference().type.sizeof)\\n\"\n"
250-
".ascii \" p_ = self.cpo.next(p_, groups.dereference()[\\\"N\\\"])\\n\"\n"
250+
".ascii \" p_ = self.cpo.next(p_, 15) # Use 15 because `groups.dereference()[\\\"N\\\"]` may be optimized out\\n\"\n"
251251
".ascii \" mask = self.match_occupied(pc_.cast(groups.type).dereference())\\n\"\n"
252252

253253
".ascii \" n = BoostUnorderedHelpers.countr_zero(mask)\\n\"\n"

0 commit comments

Comments
 (0)