Συντάκτης: Rainer Weikusat Ημερομηνία: Προς: dng Αντικείμενο: Re: [DNG] Pointer error in the backend of Netman
Steve Litt <slitt@???> writes: > On Thu, 10 Dec 2015 12:28:15 +0000
> Rainer Weikusat <rainerweikusat@???> wrote:
>
>> *p = 5
>>
>> is undefined behaviour.
>
> Not in the good old days. Anyone remember DOS' infamous B800 address?
'undefined behaviour' is a term from the C standard and 'using the value
of an object with automatic storage duration while indeterminate', ie,
prior to it being initialized to some value, is undefined behaviour.
For the original example, assigning the address of something whose value
happens to be 5 to a pointer is absolutely not the same as storing a 5
at the 'location' the uinitialized pointer happens to point to.
Assuming
int x = 5;
int *p = &x;
*p == 5 will be true afterwards. But the assignment changed the value of
p and not the value of *p (as that's just the same as x after p = &x).