Re: Somewhat Puzzline Error

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Thu, 15 May 2025 12:08:42 UTC
On 15 May 2025, at 01:22, Cy Schubert <Cy.Schubert@cschubert.com> wrote:
> 
> On 32-bit platforms, given this definition,
> 
> typedef uint128_t fiat_25519_uint128;

Where does uint128_t come from? On 32-bit platforms, uint128_t typically does not exist. :)

That is, clang and gcc both have a built-in __int128 declaration, but only one some platforms:

$ uname -m -r
15.0-CURRENT i386

$ clang -c int128.c
int128.c:1:10: error: __int128 is not supported on this target
    1 | unsigned __int128 foo = 42;
      |          ^
1 error generated.

$ gcc -c int128.c
int128.c:1:10: error: '__int128' is not supported on this target
    1 | unsigned __int128 foo = 42;
      |          ^~~~~~~~



> The following should be ok.
> 
>  fiat_25519_uint128 x26 = (x25 + (x10 + (x9 + (x7 + x4))));
>  uint64_t x27 = (uint64_t)(x26 >> 51);
> 
> But on 32-bit platforms only this results in the following error.
> 
> In file included from /home/cy/src-krb5/crypto/krb5/src/plugins/preauth/spake/ed
> wards25519.c:193:
> /home/cy/src-krb5/crypto/krb5/src/plugins/preauth/spake/edwards25519_fiat.h:101:
> 33: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
>  101 |   uint64_t x27 = (uint64_t)(x26 >> 51);
>      |                                 ^  ~~
> x26 should be 128 bits. Or is uint128_t not 128 bits on 32-bit platforms?

I think some header is typedef'ing uint128_t to something that isn't 128 bit at all.

-Dimitry