Skip to content

vector_algorithms.cpp: avoid unaligned access - #5760

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
AlexGuteniev:fear-of-misaligned
Oct 10, 2025
Merged

vector_algorithms.cpp: avoid unaligned access#5760
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
AlexGuteniev:fear-of-misaligned

Conversation

@AlexGuteniev

@AlexGuteniev Alex Guteniev (AlexGuteniev) commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

Fixes #5741

The unaligned access here could happen without misalignment from the user side: the original arrays could be of a type with a smaller alignment.

I have not found other instances of unaligned access due to integral cast

@AlexGuteniev

Copy link
Copy Markdown
Contributor Author

I didn't run with UBSan.

Whereas vector_algorithms.cpp does compile with clang-cl now, it is challenging to build cl/clang-cl hybrid STL binaries, even more so to make the rest of separately compiled code compile with clang-cl.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Ready To Merge in STL Code Reviews Oct 8, 2025
@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Oct 9, 2025
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit f3eff99 into microsoft:main Oct 10, 2025
39 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Oct 10, 2025
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing the alignment problem! 🤖 📈 💥

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vector_algorithms.cpp: undefined behavior

2 participants