Open firewave opened 1 week ago
@llvm/issue-subscribers-clang-tidy
Author: Oliver Stöneberg (firewave)
Some experiments (independent from libc++
:
struct S {
bool b{};
void operator()() {
if (b)
throw 1;
}
};
void f(bool b) {
if (b)
throw 1;
}
struct OnExit1 {
S s;
~OnExit1() {
s(); // warning
}
};
struct OnExit2 {
~OnExit2() {
f(false); // warning
}
};
struct OnExit3 {
~OnExit3() {
int* p = new int[1000]; // no warning
}
};
I suspect the libc++/libstdc++ difference has to do with the number of abstraction layers we use to implement std::function
in libc++, but I don't think that's a libc++ bug per se. Untagging.
https://godbolt.org/z/PG8M7jeE9
This is reported for any file which includes it (even when unused) when using
libc++
. There is no warning withlibstdc++
.First I think this should only be reported when it is used. And second as you cannot annotate the function with
noexcept
it should only be reported when the provided function does not throw an exception.