[Bug c/90081] stdint constant macros evaluating to wrong type
harald at gigawatt dot nl
gcc-bugzilla@gcc.gnu.org
Mon Apr 15 10:44:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90081
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #4 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Martin Sebor from comment #3)
> UINT8_C(-5) isn't valid but expanding the macros to their arguments isn't
> conforming either. C11 DR #456 suggests compiler magic is necessary to make
> the macros correct:
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_456 (Also see
> C99 DR 209: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_209.htm).
It doesn't seem like compiler magic is really needed:
#define UINT8_C(x) ((__uint8_t) +(x##U))
This works correctly even in #if expressions because of the replacement of
__uint8_t by 0.
More information about the Gcc-bugs
mailing list