[Cryptography] GCC bug 30475 (was Re: bounded pointers in C)
Viktor Dukhovni
cryptography at dukhovni.org
Fri Apr 25 00:08:51 EDT 2014
On Thu, Apr 24, 2014 at 11:18:00PM -0400, Jerry Leichter wrote:
> I believe C99 guarantees that int's representation is either 1's
> or 2's complement. That makes it easy to produce the maximum value
> for a signed type. Assume we know T is some signed integral type.
That may be a reasonable constraint on the target architecture in
my case, but:
> T max = ~(T)0;
> if (max == 0)
> { // 1's complement
> T sign_bit = 1;
> while (sign_bit > 0)
> sign_bit <<= 1;
Left shift of signed quantities, is undefined and hostile compilers
are free to do as they please here.
--
Viktor.
More information about the cryptography
mailing list