Silence ABI warning C5291 for the entire STL #5645
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverse-mirrored from toolset update MSVC-PR-650818 targeting MSVC
main
.The compiler has implemented a new warning C5291: "'DERIVED': deriving from the base class 'BASE' can cause potential runtime issues due to an ABI bug. Recommend adding a 4-byte data member to the base class for the padding at the end of it to work around this bug." This is emitted in the STL for
basic_iostream
andbasic_ostringstream
, which each derive frombasic_ostream
, when we try to self-build MSVC with a sufficiently updated compiler.Whatever this ABI bug is, it's frozen in our layout of
basic_ostream
. Since we can't do anything about it until vNext, I'm globally suppressing it in the STL, with a TRANSITION, ABI comment.I considered fine-grained suppression around
basic_iostream
andbasic_ostringstream
, in case we wanted to leave this warning active for newly added internal classes, but the risk seems low; we virtually never use multiple inheritance in internal classes. To avoid risk for the internal toolset update, I went with the global suppression.The compiler warning was implemented on 2025-06-03 by MSVC-PR-640189, where @xiangfan-ms said:
I noticed the "off-by-default" part after making this change in MSVC; I'll follow up later to add our usual "(/Wall)" comment. Fortunately, this means that it won't cause warnings for users in our supported /W4 scenarios.