Comparing D vs C++ (wierd behaviour of C++)
Ecstatic Coder
ecstatic.coder at gmail.com
Tue Jul 24 22:32:24 UTC 2018
On Tuesday, 24 July 2018 at 21:03:00 UTC, Patrick Schluter wrote:
> On Tuesday, 24 July 2018 at 19:39:10 UTC, Ecstatic Coder wrote:
>>> He gets different results with and without optimization
>>> because without optimization the result of the calculation is
>>> spilled to the i unsigned int and then reloaded for the print
>>> call. This save and reload truncated the value to its real
>>> value. In the optimized version, the compiler removed the
>>> spill and the overflowed value contained in the register is
>>> printed as is.
>>
>> Btw you are actually confirming what I said.
>>
>> if (i != 0xFFFFFFFF) ...
>>
>> In the optimized version, when the 64 bits "i" value is
>> compared to a 32 bits constant, the test fails...
>>
>> Proof that the value is stored in a **64** bits register, not
>> 32...
>
> We're nitpicking over vocabulary. For me buffer != register.
> Buffer is something in memory in my mental model (or is
> hardware like the store buffer between register and the cache)
> but never would I denominate a register as a buffer.
Pick the word you prefer, the i value is stored in a 64 bits
"place", hence the weird behavior.
More information about the Digitalmars-d
mailing list