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

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 *')

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