Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2003-01-26 21:37:49


At 06:16 PM 1/26/2003, David Abrahams wrote:
>Daniel Frey <d.frey_at_[hidden]> writes:
>
>> On Sun, 26 Jan 2003 18:50:13 +0100, David Abrahams wrote:
>>
>>> Hum. It's fine to make Peter's particular example defined, but I'm a
>>> little concerned about asking to lift *all* undefined behavior for
>>
>> Maybe I'm missing something, but what about a pointer to some type T and
>> this:
>>
>> if( p ) p->f();
>>
>> If p is 0, p->f(); is undefined, isn't it? But just because the
>> expression may be undefined (given some conditions or not) cannot make
>> the whole program undefined if the expression is not executed, right?
>> Otherwise the language would be completly useless...
>
>Yes, but normally there's no way to detect that p will be 0 at
>compile-time. If, however, you write:
>
> T* p = 0;
> if (p) p->f();
>
>I think undefined behavior is allowed to be manifested during
>translation.

Really? Why do you think that?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk