Fix ARMv5 atomic loads from Boost dummy storage

This commit is contained in:
Antonio SJ Musumeci 2026-11-14 18:19:46 -06:00 • committed by trapexit
parent ecb4de5bc0
commit 6d138906ec
3 changed files with 18 additions and 3 deletions

View file

@ -15,3 +15,6 @@
* ./bootstrap.sh
* ./b2 tools/bcp
* ./dist/bin/bcp unordered/concurrent_flat_map.hpp <target_dir>
* local patch: keep unordered dummy-group storage writable with C++20
`constinit`; ARMv5 atomic loads can write back to memory (#1695).
Preserve this change when updating Boost.

View file

@ -16,6 +16,7 @@
#include "str.hpp"
#include "thread_pool.hpp"
#include <boost/unordered/concurrent_flat_map.hpp>
#include <atomic>
#include <chrono>
#include <cstring>
@ -57,6 +58,15 @@ test_nop()
TEST_CHECK(true);
}
void
test_boost_concurrent_flat_map_empty_lookup()
{
boost::concurrent_flat_map<int,int> map;
// An unallocated map uses dummy metadata; atomic reads must be safe on ARMv5.
TEST_CHECK(map.count(42) == 0);
}
void
test_config_bool()
{
@ -4244,6 +4254,7 @@ test_clonepath_modes()
TEST_LIST =
{
{"nop",test_nop},
{"boost_concurrent_flat_map_empty_lookup",test_boost_concurrent_flat_map_empty_lookup},
{"config_bool",test_config_bool},
{"config_uint64",test_config_uint64},
{"config_int",test_config_int},

View file

@ -949,13 +949,14 @@ Group* dummy_groups()
* we are not allocating any dynamic memory and yet lookup can be implemented
* without checking for groups==nullptr. This space won't ever be used for
* insertion as the container's capacity is precisely zero.
* Keep the storage writable: atomic loads on ARMv5 can write back through
* compare-and-swap. constinit preserves static initialization without const.
*/
static constexpr typename Group::dummy_group_type
static constinit typename Group::dummy_group_type
storage[Size]={typename Group::dummy_group_type(),};
return reinterpret_cast<Group*>(
const_cast<typename Group::dummy_group_type*>(storage));
return reinterpret_cast<Group*>(storage);
}
template<