In Xcode 7 some C++ code of mine has started being flagged with a new warning:
Value.cc:45:13: error: 'this' pointer cannot be null in well-defined C++ code;
comparison may be assumed to always evaluate to false
[-Werror,-Wtautological-undefined-compare]
if (this == NULL) return kNull;
^~~~ ~~~~
Did one of the newer C++ standards declare that a non-virtual method call to a
NULL receiver is undefined behavior? Seems like an odd decision, since a
non-virtual call is just a normal function call with an implicit ‘this’
parameter. (Obviously dereferencing any member variables of ‘this’ will produce
undefined behavior, i.e. a crash, which is why you’d do the above test first if
this is a supported thing in your class.)
I know I could explicitly disable that warning, but (a) it makes it harder for
other people to use my code, and (b) I don’t want to go violating standards if
I can help it.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com
This email sent to [email protected]