Skip to content

GH-49586: [C++][CI] StructToStructSubset test failure with libc++ 22.1.1#49682

Merged
kou merged 1 commit intoapache:mainfrom
tadeja:multimap-extract-scalar-cast-test
Apr 7, 2026
Merged

GH-49586: [C++][CI] StructToStructSubset test failure with libc++ 22.1.1#49682
kou merged 1 commit intoapache:mainfrom
tadeja:multimap-extract-scalar-cast-test

Conversation

@tadeja
Copy link
Copy Markdown
Contributor

@tadeja tadeja commented Apr 7, 2026

Rationale for this change

Fixes #49586

std::multimap::extract(key) does not guarantee returning the first element when there are duplicate keys.

What changes are included in this PR?

Replace extract(key) with lower_bound(key) plus erase(iterator). lower_bound guarantees first matching element, then read it->second and then erase the node (extract is not needed as the node isn't reused here).

Are these changes tested?

Yes, CI jobs are passing.

Are there any user-facing changes?

No.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

⚠️ GitHub issue #49586 has been automatically assigned in GitHub to PR creator.

@tadeja
Copy link
Copy Markdown
Contributor Author

tadeja commented Apr 7, 2026

@pitrou

Copy link
Copy Markdown
Contributor

@zanmato1984 zanmato1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Thanks for fixing this!

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Apr 7, 2026
@zanmato1984
Copy link
Copy Markdown
Contributor

Thanks for the fix.

Switching from std::multimap::extract(key) to lower_bound(key) + erase(iterator) is the right change here. It makes duplicate-field selection deterministic (first matching field) and matches the expected behavior covered by the existing StructToStructSubset duplicate-name tests.

LGTM.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a libc++ 22.1.1 behavioral difference causing StructToStructSubset failures by making selection of duplicate struct field names deterministic when mapping input struct fields to output struct fields.

Changes:

  • Replace std::multimap::extract(key) with lower_bound(key) + erase(it) to reliably pick the first matching entry for duplicate keys.
  • Update inline comments to document why lower_bound is required for deterministic behavior across standard library implementations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@kou kou merged commit 35fb62e into apache:main Apr 7, 2026
58 checks passed
@kou kou removed the awaiting committer review Awaiting committer review label Apr 7, 2026
@github-actions github-actions bot added the awaiting merge Awaiting merge label Apr 7, 2026
@conbench-apache-arrow
Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 35fb62e.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.

raulcd pushed a commit that referenced this pull request Apr 8, 2026
…1.1 (#49682)

### Rationale for this change
Fixes #49586

`std::multimap::extract(key)` does not guarantee returning the first element when there are duplicate keys.

### What changes are included in this PR?
Replace extract(key) with lower_bound(key) plus erase(iterator). `lower_bound` guarantees first matching element, then read `it->second` and then `erase` the node (`extract` is not needed as the node isn't reused here).

### Are these changes tested?
Yes, CI jobs are passing.

### Are there any user-facing changes?
No.
* GitHub Issue: #49586

Authored-by: Tadeja Kadunc <tadeja.kadunc@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@tadeja tadeja deleted the multimap-extract-scalar-cast-test branch April 9, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][CI] StructToStructSubset test failure with libc++ 22.1.1

4 participants