• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Optimization Level
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimization Level


  • Subject: Re: Optimization Level
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 17 Oct 2016 11:45:17 -0700

> On Oct 17, 2016, at 11:35 AM, Raglan T. Tiger <email@hidden> 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.

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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 email@hidden


References: 
 >Optimization Level (From: "Raglan T. Tiger" <email@hidden>)

  • Prev by Date: Optimization Level
  • Next by Date: inconsistencies in view renderings
  • Previous by thread: Optimization Level
  • Next by thread: inconsistencies in view renderings
  • Index(es):
    • Date
    • Thread