Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: What is your opinion about unsigned int u = -2 ?
Date: Sun, 11 Aug 2024 13:57:07 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <86mslin5gc.fsf@linuxsc.com>
References: <87bk2cecan.fsf@bsb.me.uk> <87r0b6g3qx.fsf@nosuchdomain.example.com> <87jzgxdv9x.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 11 Aug 2024 22:57:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e27eccf1f18fd326d4b617bedae077c0"; logging-data="3026560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191Jou1rZHuNjnB9A5gbbPP4Q82ob28ieI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:R1/CzlewhoYTFgrNqYAieC0xISc= sha1:8hYTqTY3BtpK6YdpbGWp2I1IEQ4=
Xref: csiph.com comp.lang.c:387486
Keith Thompson writes:
> Thiago Adams writes:
>
>> More samples..
>> max uint64 + 1 is signed 128 bits in gcc and unsigned long long in clang
>>
>> #ifdef __clang__
>> static_assert(TYPE_IS(9223372036854775808, unsigned long long ));
>> #else
>> static_assert(TYPE_IS(9223372036854775808, __int128));
>> #endif
>>
>> https://godbolt.org/z/hveY44ov4
>
> 9223372036854775808 is 2**63, or INT64_MAX-1, not UINT64_MAX-1.
Of course you meant INT64_MAX + 1 (and presumably UINT64_MAX + 1).