On 06/08/20 12:45 -0600, Martin Sebor via Libstdc++ wrote:
On 8/6/20 10:00 AM, Jonathan Wakely wrote:
On 06/08/20 09:17 -0600, Martin Sebor via Libstdc++ wrote:
Sorry. I don't see this exercise as a complete waste of time
(but I understand why it feels like that to you).
What it highlights is the fact that the warning infrastructure
we have in place is far from optimal for C++ in general (with
its heavy reliance on ilining and templates) and the standard
library in particular (especially with -Wno-system-headers).
We should make an effort to do better.
Setting aside the effort to clean up the library so that it can
be used even with -Wsystem-headers,
Yeah, it's an ongoing effort.
warnings about out of bounds
accesses should trigger even with -Wno-system-headers. If one
doesn't I'd tend to view it as a bug.
I agree. And __attribute__((__warning__(""))) too.
I've opened four bugs to track some of the issues we've discussed:
96502, 96503, and 96505 for the lost attribute effect after
inlining, and 96508 for the system header interaction. I wasn't
able to reproduce the problem you're having with the attribute
(calling an out-of-line function declared in a system header
does produce a warning) so if you're not completely put off
by your experience so far please take a look at it and see
what I may have missed.
This preprocessed code fails to warn without -Wsystem-headers:
# 1 "user.C"
# 1 "sys.h" 1
# 2 "sys.h" 3
# 3 "sys.h" 3
__attribute__((warning("badness")))
void diagnose_badness();
template<typename T>
void foo(T t)
{
if (t < 0)
diagnose_badness();
}
# 2 "user.C" 2
# 3 "user.C"
int main()
{
int i = -1;
foo(i);
}