[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity
Tom Honermann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 18 11:01:35 PDT 2023
tahonermann added inline comments.
================
Comment at: clang/include/clang/Parse/Parser.h:1190
class ParseScopeFlags {
Scope *CurScope;
+ unsigned OldFlags = 0;
----------------
shafik wrote:
> @tahonermann I feel like we should have a default member initializer for any member that by default is not initialized. I realize in this case there currently should be no way for this to be bot initialized but that may not stay true and I don't believe there will be a penalty for doing this since it is initialized in the `mem-initializer-list` and therefore the default init should be omitted when calling the constructor.
I think that is very reasonable and I'm not opposed to such a policy. Per my other comment, the trade off to always initializing is that a default initializer can prevent use of tools like ubsan to discover when an appropriate (presumably non-default) value has not been assigned. I suspect (but have no data to draw on) that adding a default member initializer prevents more bugs than would be found by tools like ubsan detecting use of an uninitialized data member that should have a (non-default) assigned value.
I'm definitely in favor of using default member initializers over `mem-initializer-list`!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150744/new/
https://reviews.llvm.org/D150744
More information about the cfe-commits
mailing list