KEMBAR78
`vector_algorithms.cpp`: avoid unaligned access by AlexGuteniev · Pull Request #5760 · microsoft/STL · GitHub
Skip to content

Conversation

@AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented Oct 4, 2025

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 AlexGuteniev requested a review from a team as a code owner October 4, 2025 07:42
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Oct 4, 2025
@AlexGuteniev
Copy link
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 StephanTLavavej added the bug Something isn't working label Oct 4, 2025
@StephanTLavavej StephanTLavavej self-assigned this Oct 4, 2025
@StephanTLavavej StephanTLavavej removed their assignment Oct 8, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Oct 8, 2025
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Oct 9, 2025
@StephanTLavavej 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
Member

Thanks for fixing the alignment problem! 🤖 📈 💥

@AlexGuteniev AlexGuteniev deleted the fear-of-misaligned branch October 10, 2025 09:18
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

Archived in project

Development

Successfully merging this pull request may close these issues.

vector_algorithms.cpp: undefined behavior

2 participants