Help stabilising mini-gmp

Marc Glisse marc.glisse at inria.fr
Fri Nov 25 17:55:39 UTC 2016


On Fri, 25 Nov 2016, Torbjörn Granlund wrote:

> Marc Glisse <marc.glisse at inria.fr> writes:
>
>  Surprisingly, shifting negative numbers left is undefined, while
>  shifting them right it implementation-defined.
> 
> I fail to appreciate the difference between these definitions of
> undefinedness.
>
> I assume "undefined" means that the computer will not explode, or even
> cause any less dramatic security issues, or even terminate execution.
> It's undefined only in that the result can be any bit pattern.  This bit
> pattern might vary bewteen any two computers, with used compiler and
> between two executions.

Actually, yes, "undefined behavior" means that the computer can explode, 
execution can be terminated (what happens with the sanitizer), etc.

> And "implementation-defined" means that the bit pattern can be anything,
> varying between computers (or compiler on one computer).

"Implementation-defined value" means that every compiler must return a 
value, and document what that value is (in practice, arithmetic shift).

-- 
Marc Glisse


More information about the gmp-devel mailing list