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.
[C] Warn on uninitialized const objects #137166
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
[C] Warn on uninitialized const objects #137166
Changes from all commits
bb184fc
c3aef49
f8e1760
32daa84
6773ce9
ef89962
1e34563
c642095
b23359e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@AaronBallman I just came across this diagnostic. Why did we chose to mention the incompatibility with C++? I found it odd because the diagnostic is showing up when building a C source file. If the code was in an inline function in a header (that could be consumed from C++) then I think it would make sense to mention incompatibility with C++ but if it's in a C source file it makes less sense to me. When I'm building C source files I don't typically think (or care) about what would happen if I were to build the source file with C++ instead of C.
Really not a huge deal but I'd like to understand the reasoning and here.
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.
Good question! I wish I didn't. :-D We don't have a way to know whether a particular warning group is enabled, so there's no way to tell the difference between the user passing no flags and getting the default-enabled
-Wdefault-const-init-unsafe
, whether they passed-Wdefault-const-init-unsafe
explicitly, or whether they passed-Wc++-compat
. We just can tell that thewarn_default_init_const_unsafe
diagnostic itself is/is not ignored at a particular source location. So I don't have a good way to drop/add the "and is incompatible with C++" because I don't have a way to test "did the user explicitly opt in to-Wc++-compat
.However, maybe I can hack around this by adding a new off-by-default fake diagnostic that is never emitted by Clang but is in the
-Wc++-compat
warning group. If that diagnostic is enabled, it must mean the user passed-Wc++-compat
...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 posted #138266 to try to improve this, thank you for bringing it up!