Andrew Koenig a écrit :
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
>Does the standard define the meaning of 'evaluate' ? Someone
in another newsgroup said they thought evaluating a pointer
meant dereferencing it, and I couldn't find any text to contradict
this.
If evaluating a pointer meant dereferencing it, the following code fragment
would have undefined behavior:
int* p = 0;
int* q = p;
because (a) initializing q requires evaluating p and (b) dereferencing a
zero pointer evokes undefined behavior.
That was a question I had (I didn't remember it):
3.5.4.2 note 4
The effect of using an invalid pointer value (including passing it to
adeallocation function) is undefined.
Is returning a pointer value actually 'using it' ?
The relevant example was:
int* f()
{
return reinterpret_cast<int*>(0x42424242);
}
Is calling f() UB because it returns an invalid pointer or is it just
using/deferencing the returned value that is UB ?
Michael