This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81928] if(!this) optimization leads to possible errors without warnings


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81928

--- Comment #2 from Matthieu Brucher <matthieu.brucher at gmail dot com> ---
No, I think the optimization is more than correct. 
The warning doesn't warn of the actual problem, if you check against nullptr,
you won't even get a warning. 
Comparing this to anything from Null to nullptr should be an error, not be
silently passed. Some people still think that it is valid because it worked in
the past and because it's a bad anti pattern.
So yes, it should be rejected because it's only point is to compare the pointer
to nullptr, which is not sane. And it must be rejected because gcc in optimized
mode considers this to be always not nullptr, and doesn't even warn that the
expression is thus constant. The user doesn't know that he screwed big time.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]