New issue 989 by srpgilles: Segmentation fault after upgrade to 0.17 on macOS 11.6.2
https://github.com/include-what-you-use/include-what-you-use/issues/989
After upgrading to IWYU 0.17 on my BigSur installation (within Homebrew), IWYU stopped working on my codebase due to some pesky segmentation fault.
By trial and error on one file that was segmenting I was able to reduce to a small snippet that cause the segmentation fault:
````
#include <algorithm>
#include <cassert>
#include <vector>
int main()
{
constexpr auto unused = static_cast<std::size_t>(-1);
const auto Ndof = 100ul;
std::vector<std::size_t> mapping(Ndof, unused);
assert(std::none_of(mapping.cbegin(),
mapping.cend(),
[](auto value)
{
return value == unused;
}));
return EXIT_SUCCESS;
}
````
This segmentation fault is highly specific:
- If the algorithm is not inside the `assert` command, no segmentation fault.
- If I declare the lambda as a variable `auto is_unused = [](auto value) {... } ` and then use `is_unused` in the `std::none` algorithm, no segmentation fault.
Before the upgrade to newest IWYU (LLVM was also upgraded - I did it through `brew upgrade`), IWYU was working on my entire codebase without issue.