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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Given that all values printed that way are 0..0xff or 0..0xffff, I think better
would be to cast those to unsigned int and use %u, or cast to long and keep
using %ld.
C/C++ guarantee int is at least 16-bit and long is at least 32-bit, which is
enough to hold all those values.
So say instead of
fprintf (file, "#%ld", (INTVAL (x) >> 8) & 0xff);
use
fprintf (file, "#%ld", (long) ((INTVAL (x) >> 8) & 0xff));
or
fprintf (file, "#%u", (unsigned) ((INTVAL (x) >> 8) & 0xff));
(the & 0xff cases can be even (int) and %d) rather than the even longer
fprintf (file, "#" HOST_WIDE_INT_PRINT_DEC, (INTVAL (x) >> 8) & 0xff);

Reply via email to