[Bug c++/110798] [12 Regression] The reusult of sizeof operator followed with an 'unsigned typedef-ed generic integer' type is alway 4 bytes(except char)

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 25 10:39:55 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110798

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to miles from comment #0)
>     typedef char ch_t;
>         assert( sizeof(unsigned char) == 1); //right
>         assert( sizeof(ch_t) == 1 ); //right
>         assert( sizeof(unsigned ch_t) == 1); //the only one right

This is not valid C++, you can't use 'signed' and 'unsigned' with typedefs.

Use std::make_unsigned_t<ch_t>


More information about the Gcc-bugs mailing list