-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<vector>: Avoid off-by-default warning C4365 in vector<bool> copy algorithms with /J
#6013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<vector>: Avoid off-by-default warning C4365 in vector<bool> copy algorithms with /J
#6013
Conversation
…char` (when treated as unsigned under `/J`).
…on`. Add lots of `static_cast<ptrdiff_t>` and a few `static_cast<size_t>`. prefix.lst is what adds `/w14365`. Cleanup: Avoid unnecessary `next()`.
|
@davidmrdavid I've pushed a commit to use |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
I had to push an additional commit because |
davidmrdavid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-approving post unsigned char and pure incompatibility fixes. LGTM!
Reported by a major customer.
Our policy is that we attempt to be
/W4clean but not/Wallclean, as/Wallcontains a large number of extremely noisy warnings, many of which aren't suitable for using in production (some are intended for focused investigations, or were added for one unusual scenario, or were just way noisier than their value proved to be).However, we generally do attempt to keep the codebase clean with respect to the off-by-default warning C4365, as we build our tests with
/w14365:STL/tests/std/tests/prefix.lst
Line 6 in 4634ad4
Under the extremely obscure compiler option
/J,charis treated as an unsigned type. This triggers C4365 signed/unsigned mismatch warnings when assigning promotedinttocharin thevector<bool>optimization forcopy()implemented by #3353 (merged 2023-09-21, shipped in MSVC Build Tools 14.39 / VS 2022 17.9).Avoiding those warnings is easy, so even though
/Jis rarely used, and we don't officially support being C4365 clean, we may as well silence them and add test coverage.Enabling the test coverage is significantly more obnoxious but all of the issues were in the test itself and are avoidable with repetitive casts.