Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #11020

Re: CHello *p = 0; p->f(); /* what does spec say about this*/

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "Bo Persson" <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: CHello *p = 0; p->f(); /* what does spec say about this*/
Date Thu, 20 Oct 2011 17:45:25 +0200
Lines 20
Message-ID <9gau0cFseoU1@mid.individual.net> (permalink)
References <764b3f1e-9b4e-495d-81ef-ec5a65264c9c@r2g2000prh.googlegroups.com>
X-Trace individual.net gBzp//phfkDoIIcWYlsyaw/POOPgYDKlsHCLZ+DyjUFJ3n74bL
Cancel-Lock sha1:npXid1nVC1FDtHrhLxNruRM/7EM=
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6109
X-RFC2646 Format=Flowed; Original
X-Antivirus avast! (VPS 111020-1, 2011-10-20), Outbound message
X-Antivirus-Status Clean
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:11020

Show key headers only | View raw


lovecreatesbeauty wrote:
> class CHello{
> public:
> void f(){};
> };
>
> int main()
> {
> CHello *p = 0;
> p->f(); /* undefined behavior? what does spec say about this*/
> return 0;
> }

You are not allowed to dereference a null pointer so, yes, this is 
undefined.


Bo Persson

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

CHello *p = 0; p->f(); /* what does spec say about this*/ lovecreatesbeauty <lovecreatesbeauty@gmail.com> - 2011-10-20 07:24 -0700
  Re: CHello *p = 0; p->f(); /* what does spec say about this*/ Leigh Johnston <leigh@i42.co.uk> - 2011-10-20 16:12 +0100
  Re: CHello *p = 0; p->f(); /* what does spec say about this*/ "Bo Persson" <bop@gmb.dk> - 2011-10-20 17:45 +0200
    Re: CHello *p = 0; p->f(); /* what does spec say about this*/ lovecreatesbeauty <lovecreatesbeauty@gmail.com> - 2011-10-20 10:55 -0700
      Re: CHello *p = 0; p->f(); /* what does spec say about this*/ Victor Bazarov <v.bazarov@comcast.invalid> - 2011-10-20 14:09 -0400
      Re: CHello *p = 0; p->f(); /* what does spec say about this*/ Robert Wessel <robertwessel2@yahoo.com> - 2011-10-20 13:19 -0500

csiph-web