diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2025-04-25 08:21:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-25 08:21:41 -0400 |
commit | 576161cb6069e2c7656a8ef530727a0f4aefff30 (patch) | |
tree | d099c1de03f3add52656ecbba87e7f5ed19993b8 /clang/lib/Frontend/ASTMerge.cpp | |
parent | 320ec7fa7f2ca9385e355d3e031e601a9e331e3e (diff) | |
download | llvm-576161cb6069e2c7656a8ef530727a0f4aefff30.zip llvm-576161cb6069e2c7656a8ef530727a0f4aefff30.tar.gz llvm-576161cb6069e2c7656a8ef530727a0f4aefff30.tar.bz2 |
[C] Warn on uninitialized const objects (#137166)
Unlike C++, C allows the definition of an uninitialized `const` object.
If the object has static or thread storage duration, it is still
zero-initialized, otherwise, the object is left uninitialized. In either
case, the code is not compatible with C++.
This adds a new diagnostic group, `-Wdefault-const-init-unsafe`, which
is on by default and diagnoses any definition of a `const` object which
remains uninitialized.
It also adds another new diagnostic group, `-Wdefault-const-init` (which
also enabled the `unsafe` variant) that diagnoses any definition of a
`const` object (including ones which are zero-initialized). This
diagnostic is off by default.
Finally, it adds `-Wdefault-const-init` to `-Wc++-compat`. GCC diagnoses
these situations under this flag.
Fixes #19297
Diffstat (limited to 'clang/lib/Frontend/ASTMerge.cpp')
0 files changed, 0 insertions, 0 deletions