[libcxx-commits] [libcxx] [libc++] Optimize {std, ranges}::for_each for iterating over __trees (PR #164405)

Nico Weber via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 16 17:53:17 PST 2025


nico wrote:

This program crashes at HEAD for me, but works before this PR:

```
% cat ui/actions/actions_unittest.cc 
#include <stdio.h>

#include <algorithm>
#include <iterator>
#include <map>
#include <set>

int main() {
  fprintf(stderr, "making a context\n");

  {
    using PropMap = std::map<const void*, int>;
    PropMap prop_map_;

    static constexpr auto dealloc = [](int& v) {};
    std::ranges::for_each(prop_map_, dealloc, &PropMap::value_type::second);
  }

  fprintf(stderr, "survived\n");
}
```

https://github.com/llvm/llvm-project/pull/164405


More information about the libcxx-commits mailing list