This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81928] if(!this) optimization leads to possible errors without warnings
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 23 Aug 2017 19:49:35 +0000
- Subject: [Bug c++/81928] if(!this) optimization leads to possible errors without warnings
- Auto-submitted: auto-generated
- References: <bug-81928-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81928
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Matthieu Brucher from comment #8)
> What is fundamentally wrong is stated in the standard. It is an undefined
> behavior to call a method from a null pointer. So testing this inside a
> method is an undefined behavior
Nonsense.
It can never be null, but it's not undefined to check that. It's 100% defined
that this==nullptr is always false.