Skip to content
Snippets Groups Projects
Commit f85ea42c authored by Alexander Pivovarov's avatar Alexander Pivovarov Committed by TensorFlower Gardener
Browse files

PR #22822: Fix ambiguous constructor call in SourceTargetPairs initialization

Imported from GitHub PR https://github.com/openxla/xla/pull/22822

### Description
Resolve a build failure (with GCC-11) in `collective_permute_cycle_test` caused by an ambiguous constructor call when initializing `SourceTargetPairs` with an empty list (`{{}}`).

#### Issue
When calling `SourceTargetPairs({{}})`, the compiler could not determine whether to use the `std::vector<std::pair<int64_t, int64_t>>` constructor or the default copy/move constructors, leading to an error:
```
xla/service/collective_permute_cycle_test.cc:130:48: error: call of overloaded 'SourceTargetPairs(<brace-enclosed initializer list>)' is ambiguous
  130 |   EXPECT_EQ(GetCycleType(SourceTargetPairs({{}})), CycleType::kNone);
```

#### Solution
1. Explicitly define an `initializer_list` constructor for `SourceTargetPairs` to properly handle `{}` and `{{src, tgt}}` initializations.
2. Update the test case to use default ctor `SourceTargetPairs()` instead of `SourceTargetPairs({{}})`, ensuring clarity and correctness.

This fix ensures proper initialization and eliminates ambiguity

Tested with GCC-11
Copybara import of the project:

--
f97c38d47c8373ec609fdfbaedff3856f123fc33 by Alexander Pivovarov <pivovaa@amazon.com>:

Fix ambiguous constructor call in SourceTargetPairs initialization

Merging this change closes #22822

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/22822 from apivovarov:fix_source_target_pairs f97c38d47c8373ec609fdfbaedff3856f123fc33
PiperOrigin-RevId: 730590032
parent 10f8a189
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment