Skip to content

Fix vectorized replace_copy for bool arrays, also test replace - #6381

Merged
Stephan T. Lavavej (StephanTLavavej) merged 11 commits into
microsoft:mainfrom
AlexGuteniev:bool-trap
Jul 28, 2026
Merged

Fix vectorized replace_copy for bool arrays, also test replace#6381
Stephan T. Lavavej (StephanTLavavej) merged 11 commits into
microsoft:mainfrom
AlexGuteniev:bool-trap

Conversation

@AlexGuteniev

@AlexGuteniev Alex Guteniev (AlexGuteniev) commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Copilot has discovered a bug in replace vectorization for 8-bit elements that is being implemented. Stephan T. Lavavej (@StephanTLavavej) observed that replace_copy has already this bug in. This PR fixes the bug.

The problem happens when vectorized replace is called for bool array and the replacement is an integer that is a non-value representation when converted to bool.

Due to _Could_compare_equal_to_value_type we don't have the comparand equivalent of this problem.

Since there are only two algorithms that need such handling (replace and replace_copy), and only one exact type, I think we should just dispatch it separately.

Copilot AI review requested due to automatic review settings July 26, 2026 14:22
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Jul 26, 2026
@azure-pipelines

This comment was marked as resolved.

@azure-pipelines

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings July 26, 2026 14:29

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings July 26, 2026 14:36

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the bug Something isn't working label Jul 26, 2026
Comment thread tests/std/tests/GH_006381_replace_non_value_bool/test.cpp
Comment thread tests/std/tests/GH_006381_replace_non_value_bool/test.cpp Outdated
Comment thread tests/std/tests/GH_006381_replace_non_value_bool/test.cpp Outdated
@github-project-automation github-project-automation Bot moved this from Initial Review to Work In Progress in STL Code Reviews Jul 26, 2026
Copilot AI review requested due to automatic review settings July 26, 2026 18:57

This comment was marked as resolved.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Work In Progress to Initial Review in STL Code Reviews Jul 26, 2026
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) changed the title Fix bool array replace_copy Jul 26, 2026
Copilot AI review requested due to automatic review settings July 26, 2026 21:42
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Ready To Merge in STL Code Reviews Jul 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Medium
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Jul 27, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 059ee42 into microsoft:main Jul 28, 2026
48 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Jul 28, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing and testing this! 🛠️ 🪄 😻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

3 participants