[PATCH] run -Wnonnull later (PR 87489)
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Fri Feb 19 09:48:57 GMT 2021
Am 2021-02-01 um 01:31 schrieb Martin Sebor via Gcc-patches:
> The initial -Wnonnull implementation in the middle end took place
> too late in the pipeline (just before expansion), and as a result
> was prone to false positives (bug 78817). In an attempt to avoid
> the worst of those, the warning was moved to the ccp2 pass in
> r243874. However, as the test case in PR 87489 shows, this is
> in turn too early and causes other false positives as a result.
>
> A few experiments with running the warning later suggest that
> just before the mergephi2 pass is a good point to avoid this class
> of false positives without causing any regressions or introducing
> any new warnings either in Glibc or in Binutils/GDB.
>
> Since PR 87489 is a GCC 8-11 regression I propose to make this
> change on the trunk as well as on the release branches.
Hi Martin,
I tested your patch and it showed also one more warning for this
testcase with -O2 -Wnonnull:
class b {
public:
long c();
};
class B {
public:
B() : f() {}
b *f;
};
long d, e;
class g : B {
public:
void h() {
long a = f->c();
d = e = a;
}
};
class j {
j();
g i;
};
j::j() { i.h(); }
I hope cvise didn't minimize too much, but at least in the original much
larger code the warning looks reasonable too.
Franz
More information about the Gcc-patches
mailing list