> On Oct 17, 2016, at 11:35 AM, Raglan T. Tiger <r...@crusaderrabbit.net> wrote:
> void xxxxx::Clear(apointList &list)
> {
>    if ( ! &list )
>        return;
> }

It’s not valid for a C++ reference value to refer to null. So the optimizer is 
allowed to assume that `&list` is a non-null pointer, and the test in the `if` 
can never be true, and optimize out the whole `if` statement. You’ll need to 
restructure your code so that you never pass null values as references.

I ran into a similar situation a while ago, where I had a (nonvirtual) method 
that accepted a null receiver, i.e. it was safe to call `foo->bar()` even if 
`foo` was null because the method had a test `if(!this) return;`. But the C++ 
standard says that it’s illegal to call a method with a null receiver, so the 
optimizer removed the test.


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to arch...@mail-archive.com

Reply via email to