Open 4084477f-e1df-4024-a410-168c80096e18 opened 2 years ago
I'm wondering how many of those warnings are actually relevant. Given that GCC -Wmaybe-uninitialized and -Wuninitialized are known to be broken: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639 and LLVM decided to use -Wno-maybe-uninitialized perhabs only -Wfree-nonheap-object and -Walloc-size-larger-than warnings could be more than just false positives.
However after looking closer at -Walloc-size-larger-than I'm pretty sure it's false positive warning either: /home/tkloczko/rpmbuild/BUILD/clang-13.0.0rc4.src/include/clang/AST/Type.h: In member function 'setDecompositionBindings': /home/tkloczko/rpmbuild/BUILD/clang-13.0.0rc4.src/include/clang/AST/Type.h:5621: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] 5621 | /// parameter packs. It points to snippet: new DecompositionDeclarator::Binding[Bindings.size()]; Exceeding maximum object size for operator new call means that memory pointed by Bindings (ArrayRef) had to exceed it either which is unlikely. Isn't about https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85783?
Remaining 3 -Wfree-nonheap-object warnings are more tricky to analyze due to quite imprecise diagnostics. Not sure what potentially could cause in APInt divergence between BitWidth and U (leading to destruction from wrong union member).
Extended Description
gcc 11.2.1
Looks like no one have been trying to compile clang using gcc and optimise it using LTO. Just done that and LTO reported 550 [-Wmaybe-uninitialized] warnings Summary stats of all warnings:
[tkloczko@barrel SPECS]$ cat clang.out | grep -- -W | sed 's/.*[//; s/]//' | sort | uniq -c | sort -nr 550 -Wmaybe-uninitialized 13 -Wuninitialized 3 -Wfree-nonheap-object 1 -Walloc-size-larger-than=
Full log of all warnings is in attachment.