Path: csiph.com!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!border-4.nntp.ord.giganews.com!nntp.giganews.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: _BitInt(N) Date: Tue, 25 Nov 2025 19:21:03 -0800 Organization: None to speak of Lines: 40 Message-ID: <87pl95cwdc.fsf@example.invalid> References: <10dajlh$ko3c$1@dont-email.me> <10fus62$hl69$1@solani.org> <10fv2dm$3can9$1@paganini.bofh.team> <10fv40v$1f7a2$1@dont-email.me> <87ms4c4bom.fsf@example.invalid> <10g08vm$1us25$1@dont-email.me> <10g1et7$2bmus$1@dont-email.me> <10g1j7h$2deh9$1@dont-email.me> <10g1qq9$2f8lb$4@dont-email.me> <10g28gm$2mf9s$1@dont-email.me> <10g2f2d$2oufq$1@dont-email.me> <10g2m3v$2s5sa$1@dont-email.me> <10g53au$3onvh$1@dont-email.me> <10g58pa$3r273$1@dont-email.me> <877bvdk8c4.fsf@example.invalid> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 26 Nov 2025 03:21:04 +0000 (UTC) Injection-Info: dont-email.me; posting-host="6f47bd7264b2dbdf6e6603756425bf4b"; logging-data="38863"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UieZTnJSxKzoMEYO3q2tK" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:FOTAkzUS6n/a4VFWwXmFDzgUICE= sha1:nVzJr4vy244niOIxROWOmPzjyi0= Xref: csiph.com comp.lang.c:395488 Keith Thompson writes: > bart writes: [...] >> OK, so why are you not allowed to have _BitInt(1)? That is, a 1-bit >> signed integer. It might only have two values of 0 and -1; doesn't >> nobody want that particular combination? > > I don't know. The language allows 1-bit signed bit-fields, so > _BitInt(1) would make some sense, but the language requires N to > be at least 1 for unsigned _BitInt and 2 for signed _BitInt. > > It doesn't bother me too much, since I'm unlikely to have a > use for signed _BitInt(1). But it's an arbitrary restriction. [...] I just learned that there's a proposal to allow _BitInt(1) in C2y. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3699.pdf The current restriction apparently was for historical reasons. Prior to C23, C didn't require two's complement for signed types, and signed _BitInt(1) doesn't make much sense for one's complement or sign-and-magnitude (it could only hold +0 and -0). Yes, C23 added both _BitInt and the requirement for two's complement, but preliminary implementations of _BitInt go back several years, and the requirements didn't catch up. Stuff happens. Incidentally, C23 requires BITINT_MAXWIDTH to be at least ULLONG_WIDTH, which is at least 64. clang/llvm sets it to 128 for some target systems. https://eisenwave.github.io/cpp-proposals/bitint.html is a proposal to add C23-style bit-precise integers to C++. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */