C++ Logo


Advanced search

Re: [std-proposals] Slow bulky integer types (128-bit)

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Wed, 29 Mar 2023 11:18:45 -0400
On Wed, Mar 29, 2023 at 11:10 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> On Wed, Mar 29, 2023 at 3:29 PM Peter Olsson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > > The standard already defines - as you suggested - two categories:
> > > standard integer types and extended integer types.
> > > It could really make sense to introduce - as you called it -
> > > `uintmax_oversize_t` -, or better named `uintmax_extended_t` to
> > > cover both stand and extended types.
> >
> > Wouldn't uintmax_extended_t introduce the same problem again when
> > vendors wants to add new bigger extended integer types in the future?

The trick is that no foomax_bar_t can ever satisfy both criteria:
- Changes over time to keep up with reality
- Never changes
You (vendor) have to pick one or the other, and communicate your choice
clearly to the user-programmer.
`intmax_t` failed to make a choice at first, and then gradually fell into
the "Never changes" bucket, despite the fact that naïve user-programmers
will naturally *assume* it occupies the "Changes to reflect reality"
bucket. So `intmax_t` got the worst of both worlds.

A new `uintmax_extended_t` (or whatever) can communicate properly from the
get-go: "Hey! This type will change in the future! Don't build it into your
But then, if you aren't using this type in APIs, then where *are* you using
it, and why does it need to exist in the standard library at all?

Anyway, the whole idea of "max length type" is obsolete in this decade:
compilers now (and as of last year(?) the C standard, and I bet within 5
years the C++ standard) support arbitrary-width integral types using the
syntax `_BitInt(42)` or `_ExtInt(42)`. You can make arbitrarily wide types
that way, e.g. `_BitInt(1024)`, `_BitInt(sizeof(intmax_t) * 8 + 1)`, ... :)
So there's no point in worrying about "maximum length types." You can't use
them in APIs, and they don't exist anyway.

Frederick, before you bother forking GCC, you might want to just compare
the codegen you get from a library solution such as
and see if it meets your needs.


Received on 2023-03-29 15:18:58