-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Add an off-by-default warning to complain about MSVC bitfield padding #117428
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
Changes from 16 commits
3e25d7e
fbe679e
11447fe
a18c032
75a46fe
40dc8cf
bd3ffbe
c4b2d4a
e1b5296
ca50d1e
fa39d28
196c034
d88b87b
bd2b006
ab3b7c3
d3fb2f2
80e3549
5e64d46
73128b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6519,6 +6519,13 @@ def warn_signed_bitfield_enum_conversion : Warning< | |||||
| InGroup<BitFieldEnumConversion>, DefaultIgnore; | ||||||
| def note_change_bitfield_sign : Note< | ||||||
| "consider making the bit-field type %select{unsigned|signed}0">; | ||||||
| def warn_ms_bitfield_mismatched_storage_packing : Warning< | ||||||
| "bit-field %0 of type %1 has a different storage size than the " | ||||||
| "preceding bit-field (%2 vs %3 bytes) and will not be packed under " | ||||||
| "the MS Windows platform ABI">, | ||||||
|
||||||
| "the MS Windows platform ABI">, | |
| "the Microsoft ABI">, |
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.
In the codebase, we tend to use "Windows" to cover behaviors that need to be shared with GCC and MinGW, and "Microsoft" to cover behaviors that are unique to MSVC. This tends to boil down to C vs. C++. If it's part of the C ABI, it's a Windows behavior, under the rationale that any C compiler for the platform would need to match this behavior, like enums always using a fixed type of int rather than expanding to long long if the members require it. C++ behaviors are high cost and "optional".
This mostly reflects the actual coding logic required, which is to check whether the OS is Windows, or whether the "environment" is Microsoft, so perhaps this is not the best language to communicate with users
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.
Thanks for the explanation!
Would you recommend we go with Windows ABI and leave the Microsoft off? Or should we use Microsoft Windows ABI? I mostly want to avoid MS.
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.
In this context I would just say "Windows ABI".
I do recall preferring the use of the company name ("Microsoft") over the use of the product name ("MSVC" / "Visual C++") in the past for obscure legal reasons, but now that Clang ships as part of Visual Studio, clarity is more important than marginal increases in legal risk. This is probably why the code talks about the "Microsoft C++ ABI" not the "MSVC(++) ABI".
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.
SGTM!
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.
I've switched to Microsoft ABI, and the diagnostic is now ms-bitfield-padding
Uh oh!
There was an error while loading. Please reload this page.