|
From: Tom H. <to...@co...> - 2005-10-18 10:08:13
|
In message <Pin...@jd...>
Igmar Palsenberg <mai...@jd...> wrote:
>> > As far as I can tell, the whole of uninit is undefined, so is the result
>> > of the multiplication.
>> >
>> >> if(!(uninit & 1)) // there should be no error here
>> >> {
>> >
>> > uninit still contains random data. Why shouldn't it give errors ?
>>
>> He is only looking at the lowest bit and as he has doubled it that
>> bit is guaranteed to be zero and well defined.
>
> The rest of the bits aren't defined. Since you can't address anything less
> then a byte, it should give errors on these kind of operations if you ask
> me.
He is testing the bottom bit so the result of the test is perfectly
well defined - one of valgrinds strengths is that it does bit level
tracking of defined values not byte level.
>> Multiplying by two is after equivalent to a left shift by one and
>> such a shift is guaranteed to shift in a zero and hence make the
>> bottom bit well defined.
>
> You still take at least 8 bits when doing the and operation. From a
> theoretical point it makes sense and you're right. From a logical sense
> (partial) garbage in equals garbage out :)
The process may and 8 bits or 32 bits or 64 bits but only one of them
affects the result of the operation.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|