Date: Fri, 08 Aug 2025 11:38:30 -0700
On Friday, 8 August 2025 10:08:46 Pacific Daylight Time Hans Åberg via Std-
Proposals wrote:
> > Wouldn't we get it for free when we get _BitInt support?
>
> I don't know of this one, so you would have to explain. —It looks like it is
> for fixed-size, fairly small types. But C++ might benefit from that.
_BitInt is in C23. It's not yet officially part of C++, but compilers that
support it in C will support it in C++ at some point (Clang currently does,
GCC does not). There's also someone writing a paper to add std::bitint<N>.
The upper limit of N is implementation dependent. GCC 15 has an upper limit of
65535 bits and Clang's is 8388608 bits.
As you can see in https://gcc.godbolt.org/z/f5zTqrYK4,
* there already is a runtime library function for performing generic
multiprecision divisions, called __divmodbitint4[1][2]
* Clang inlined the division instead of calling the runtime library function
* the runtime library function is not public; only the compiler is allowed to
call it
* users are limited to sizes known at compile time
Your proposal right now is giving direct access to the runtime functions, by
giving them a public name.
Do we need sizes only known at runtime? If you do, wouldn't it be better to
just use libgmp or some other MP library?
[1] https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
[2] https://github.com/gcc-mirror/gcc/blob/releases/gcc-15.2.0/libgcc/
libgcc2.c#L1683
Proposals wrote:
> > Wouldn't we get it for free when we get _BitInt support?
>
> I don't know of this one, so you would have to explain. —It looks like it is
> for fixed-size, fairly small types. But C++ might benefit from that.
_BitInt is in C23. It's not yet officially part of C++, but compilers that
support it in C will support it in C++ at some point (Clang currently does,
GCC does not). There's also someone writing a paper to add std::bitint<N>.
The upper limit of N is implementation dependent. GCC 15 has an upper limit of
65535 bits and Clang's is 8388608 bits.
As you can see in https://gcc.godbolt.org/z/f5zTqrYK4,
* there already is a runtime library function for performing generic
multiprecision divisions, called __divmodbitint4[1][2]
* Clang inlined the division instead of calling the runtime library function
* the runtime library function is not public; only the compiler is allowed to
call it
* users are limited to sizes known at compile time
Your proposal right now is giving direct access to the runtime functions, by
giving them a public name.
Do we need sizes only known at runtime? If you do, wouldn't it be better to
just use libgmp or some other MP library?
[1] https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
[2] https://github.com/gcc-mirror/gcc/blob/releases/gcc-15.2.0/libgcc/
libgcc2.c#L1683
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Platform & System Engineering
Received on 2025-08-08 18:38:34