Copilot commented on code in PR #50870:
URL: https://github.com/apache/arrow/pull/50870#discussion_r3910816463
##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -519,6 +519,22 @@ std::shared_ptr<MatchConstraint> DecimalsHaveSameScale() {
return instance;
}
+std::shared_ptr<MatchConstraint> AllTypesAreIdenticalFrom(size_t
first_type_index) {
+ return MatchConstraint::Make(
+ [first_type_index](const std::vector<TypeHolder>& types) -> bool {
+ DCHECK_LT(first_type_index, types.size());
+ return std::all_of(types.begin() + first_type_index + 1, types.end(),
+ [&types, first_type_index](const TypeHolder& type) {
+ return type == types[first_type_index];
+ });
+ });
Review Comment:
AllTypesAreIdenticalFrom() relies on DCHECK_LT(first_type_index,
types.size()) and then unconditionally does iterator arithmetic / indexing. In
release builds (DCHECK compiled out), an unexpected call with too few input
types would be undefined behavior; it should defensively return false instead
of potentially reading past the end of `types`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]