Comparing D vs C++ (wierd behaviour of C++)

Patrick Schluter Patrick.Schluter at bbox.fr
Tue Jul 24 21:03:00 UTC 2018


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.


More information about the Digitalmars-d mailing list