Skip to content

Commit ecd3ac9

Browse files
knoepfelbeojan
andauthored
Fix latent memory error exposed by fixed_hierarchy_test (#668)
A weakness in GCC 15.1 was exposed when unwinding the stack due to an exception throw. --------- Co-authored-by: Beojan Stanislaus <beojan@gmail.com>
1 parent f696aa5 commit ecd3ac9

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

phlex/model/fixed_hierarchy.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ namespace {
5252
std::vector<std::vector<std::string>>&& layer_path_strings)
5353
{
5454
using namespace phlex::experimental;
55-
auto layer_paths =
56-
std::move(layer_path_strings) | std::views::transform([](std::vector<std::string>& lp) {
57-
auto lp_as_ids =
58-
lp | std::views::transform([](auto& str) { return identifier(std::move(str)); }) |
59-
std::ranges::to<std::vector>();
60-
return layer_path(std::move(lp_as_ids));
61-
}) |
62-
std::ranges::to<std::vector<layer_path>>();
55+
std::vector<layer_path> layer_paths;
56+
layer_paths.reserve(layer_path_strings.size());
57+
for (auto& lp : layer_path_strings) {
58+
auto lp_as_ids =
59+
lp | std::views::as_rvalue |
60+
std::views::transform([](std::string&& str) { return identifier(std::move(str)); }) |
61+
std::ranges::to<std::vector>();
62+
layer_paths.emplace_back(std::move(lp_as_ids));
63+
}
6364
return unique_paths(std::move(layer_paths));
6465
}
6566
}

0 commit comments

Comments
 (0)