Re: Dereferencing a null-pointer allowed?
===================================== MODERATOR'S COMMENT:
===================================== END OF MODERATOR'S COMMENT
On May 10, 6:56 am, James Kanze <james.ka...@gmail.com> wrote:
On May 8, 11:03 pm, Daniel Kr?gler <daniel.krueg...@googlemail.com>
wrote:
So yes, the essence is rather distributed among the standard, but
it is clearly expressed that you cannot use the dereferenced result
of an object pointer to access its members.
With one important exception, I believe: if the expression is
used as an argument to sizeof or typeid. Something like:
sizeof( ((T*)0)->f() )
is legal, I think.
I tried to exclude your example by saying "cannot use".
I meant "use" here in the way defined by 3.2/2:
"An expression is potentially evaluated unless it appears
where an integral constant expression is required (see 5.19),
is the operand of the sizeof operator (5.3.3), or is the
operand of the typeid operator and the expression does not
designate an lvalue of polymorphic class type (5.2.8).
An object or non-overloaded function is used if its name
appears in a potentially-evaluated expression."
Obviously my wording was not unmistakably, so thanks
for this point, James!
Greetings,
Daniel
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]