Skip to content

Commit 60fb687

Browse files
committed
Another try
1 parent 0a01031 commit 60fb687

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

r/src/compute.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,20 @@ std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
155155
}
156156

157157
if (func_name == "sort_indices") {
158+
using Key = arrow::compute::SortKey;
158159
using Order = arrow::compute::SortOrder;
159160
using Options = arrow::compute::SortOptions;
160161
auto names = cpp11::as_cpp<std::vector<std::string>>(options["names"]);
161162
// false means descending, true means ascending
162163
// cpp11 does not support bool here so use int
163164
auto orders = cpp11::as_cpp<std::vector<int>>(options["orders"]);
164-
auto out = std::make_shared<Options>();
165-
out->sort_keys.reserve(names.size());
165+
// Use resize + assignment to avoid vector growth operations that trigger
166+
// false positive -Wmaybe-uninitialized warnings in GCC 14 with std::variant
167+
std::vector<Key> keys(names.size(), Key("", Order::Ascending));
166168
for (size_t i = 0; i < names.size(); i++) {
167-
out->sort_keys.emplace_back(names[i],
168-
(orders[i] > 0) ? Order::Descending : Order::Ascending);
169+
keys[i] = Key(names[i], (orders[i] > 0) ? Order::Descending : Order::Ascending);
169170
}
171+
auto out = std::make_shared<Options>(std::move(keys));
170172
return out;
171173
}
172174

0 commit comments

Comments
 (0)