Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,647 of 33,346    |
|    =?windows-1252?Q?Daniel_Kr=FCgler?= to Carlos Moreno    |
|    Re: Reference to show that if (this == N    |
|    08 Nov 11 15:49:29    |
      From: daniel.kruegler@googlemail.com              On 2011-11-08 09:06, Carlos Moreno wrote:       > Still, it seems quite shocking that the standard would not       > explicitly say something about accessing any member through       > dereferencing a NULL pointer. Or, for that matter, simply       > stating something about dereferencing a null pointer. I       > mean, for example, what would be the wording that states       > that the following is undefined behaviour:       >       > int * p = NULL;       > int a = *p;              This follows from normative statements from two sub-clauses in the standard:              a) [basic.lval] p1:              "       — An lvalue [..] designates a function or an object.       [..]       — An xvalue (an “eXpiring” value) also refers to an object,       [..]       — A glvalue (“generalized” lvalue) is an lvalue or an xvalue.       "              This defines an lvalue/gvalue as designating/referencing a function or       object.              b) [conv.lval] p1:              "A glvalue (3.10) of a non-function, non-array type T can be converted       to a prvalue. [..] If the object to which the glvalue refers is not       an object of type T and is not an object of a type derived from T, or if       the object is uninitialized, a program that necessitates this conversion       has undefined behavior."              This makes an lvalue-to-rvalue conversion defined, if (and only if) the       converted (g)lvalue refers to an initialized object.              > How would that wording (which I'm sure there has to be some       > *explicit* statement about the undefined-behaviour-ness of the       > above) not be general enough to cover the use of a NULL pointer       > to invoke a method on the pointed (inexistent) object as well??              Your example and above quoted normative statements don't help much in       the originally discussed example, where no lvalue-to-rvalue conversion       is involved.              HTH & Greetings from Bremen,              Daniel Krügler                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca