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: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Aug 2017 22:56: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
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #23 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #22)
> Either explain more clearly what you're asking for, or accept it already
> warns about this.
The descriptive style of GCC's diagnostics is a recurrent problem for some
users who are not aware of the details of the language. We had countless of
discussions about it in the past. Clang's diagnostics tend to be more
prescriptive:
warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be
assumed to always convert to true
Some other examples:
$ gcc
error: invalid type argument of unary ‘*’ (have ‘int’)
$ clang
error: indirection requires pointer operand ('int' invalid)
$ gcc
warning: wrong type argument to increment [-Wpedantic]
$ clang
warning: arithmetic on a pointer to void is a GNU extension [-Wpointer-arith]
$ gcc
error: invalid operands to binary / (have 'float __vector__' and 'const int *')
$ clang
error: can't convert between vector values of different size ('__m128' and 'int
const *')