C++ Logo


Advanced search

Re: [std-proposals] uint_nopro_fast32_t : Types in <cstdint> that don't promote

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 1 Apr 2023 17:00:40 +0100
Link to GodBolt:


Here's the code copy-pasted:

void Func(_BitInt(127) *const parg)
    *parg += 73;

#include <iostream>

int main(void)
    _BitInt(16) i;
    std::cout << typeid(i * i).name() << std::endl;

    short j;
    std::cout << typeid(j * j).name() << std::endl;

Note that the function, 'Func', takes a 127-Bit number rather than
128-Bit, and here's the x86_64 assembler for it. The third and fourth
lines are where it gets bitwise-AND'ed to wipe out the high bit:

 add QWORD PTR [rdi],0x49
 mov rax,QWORD PTR [rdi+0x8]
 adc rax,0x0
 movabs rcx,0x7fffffffffffffff
 and rcx,rax
 mov QWORD PTR [rdi+0x8],rcx
 xchg ax,ax

I don't know what that last line is doing there after the function has
returned, by anyway moving on. . .

The short program above prints:


so this tells me that 'short' is a 16-Bit type that gets promoted to
int, and that '_BitInt(16)' is a 16-Bit type that doesn't get

Received on 2023-04-01 16:00:51