• 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: New C++ warning about comparing this==NULL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New C++ warning about comparing this==NULL


  • Subject: Re: New C++ warning about comparing this==NULL
  • From: Anders Montonen <email@hidden>
  • Date: Wed, 02 Dec 2015 22:02:30 +0200


On 02 Dec 2015, at 21:22, Jens Alfke <email@hidden> wrote:

Did one of the newer C++ standards declare that a non-virtual method call to a NULL receiver is undefined behavior?

As I understand it, it has never been legal, since calling the method requires dereferencing a NULL pointer. From ISO/IEC 14882:2003(E)), paragraph 5.2.5/3:
“If E1 has the type 'pointer to class X,' then the _expression_ E1->E2 is converted to the equivalent form (*(E1)).E2”

I wouldn’t be surprised if modern compilers removed the NULL check as impossible. See also <http://www.viva64.com/en/b/0226/>

-a
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: New C++ warning about comparing this==NULL
      • From: Jens Alfke <email@hidden>
References: 
 >New C++ warning about comparing this==NULL (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: New C++ warning about comparing this==NULL
  • Next by Date: Re: New C++ warning about comparing this==NULL
  • Previous by thread: Re: New C++ warning about comparing this==NULL
  • Next by thread: Re: New C++ warning about comparing this==NULL
  • Index(es):
    • Date
    • Thread