Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11020
| From | "Bo Persson" <bop@gmb.dk> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: CHello *p = 0; p->f(); /* what does spec say about this*/ |
| Date | 2011-10-20 17:45 +0200 |
| Message-ID | <9gau0cFseoU1@mid.individual.net> (permalink) |
| References | <764b3f1e-9b4e-495d-81ef-ec5a65264c9c@r2g2000prh.googlegroups.com> |
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
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