[Bug c/90081] stdint constant macros evaluating to wrong type

harald at gigawatt dot nl gcc-bugzilla@gcc.gnu.org
Tue Apr 16 06:57:00 GMT 2019


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

--- Comment #6 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Guy Perfect from comment #5)
> (In reply to Harald van Dijk from comment #4)
> That was my line of thinking: supplying a cast in the macro.

Keep in mind that inside #if expressions, there cannot be and will not be any
cast. That's the reason I included the + there.

> Even in the
> case of negative values being cast to unsigned types, the language spec
> provides a rule for that, so the behavior is defined independent of the
> implementation:

As Andreas Schwab pointed out, the behaviour of UINT8_C in that case is
undefined, even if the behaviour of a cast would be defined. It simply does not
matter what happens in that case.

> I think the ticket was marked "resolved invalid" prematurely, as there's
> clearly a meaningful problem and a meaningful solution.

I do think it's rightly closed, but for a reason not yet mentioned: these
macros are not defined by GCC's <stdint.h>. If this required compiler magic to
implement, it would be primarily a GCC bug, but the fact that no compiler magic
is needed means this is purely a glibc bug, so should be filed there.


More information about the Gcc-bugs mailing list