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

--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
On Sat, 13 Apr 2019, bafap5 at yahoo dot com wrote:

>   int x = sizeof ((int8_t) 5); /* Correct, gives 1 */
>   int y = sizeof (INT8_C(5));  /* Incorrect, gives 4 */

No, INT8_C(5) must expand to have type int, not int_least8_t, if 
int_least8_t promotes to int.  See 7.20.4#3, "The type of the expression 
shall have the same type as would an expression of the corresponding type 
converted according to the integer promotions.".  *Not* the type itself, 
the promoted type.

I think expanding the macro to its argument is clearly correct here, 
including for UINT8_C, as the interpretation suggested in DR#456 
regarding having an unsigned type in #if leads to the obvious absurdities 
I described in reflector message 13320 (15 May 2014).

Reply via email to