Why does GCC C++ issue
warning: nonnull parameter `this' compared to NULL
when the code being compiled is passing this
as a parameter even though this
is not being compared to NULL
or any of its equivalents?
In the constructor of a derived C++ class I pass this
as a parameter to a function which is expecting a pointer to a base class of the derived class. The constructor never compares this
against anything, much less NULL
or its equivalents. Yet when this code is compiled by GCC 8.5.0 with -std=c++11
on RHEL 8.6 on x86_64 I get
warning: nonnull parameter `this' compared to NULL
Note that I didn't get this warning when the same code is compiled by GCC 4.8.5 with -std=c++0x
on RHEL 7.9 on x86_64.
I can work around or suppress this warning, but I wonder why I'm getting this warning even though this code isn't comparing this
to NULL
or any of its equivalents.
Aucun commentaire:
Enregistrer un commentaire