This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] avoid using %lli et al.
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 21 Dec 2017 01:13:11 +0100
- Subject: Re: [PATCH] avoid using %lli et al.
- Authentication-results: sourceware.org; auth=none
- References: <82eeb084-c0b7-ec16-6c54-ef52c0d69ba1@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Dec 20, 2017 at 05:03:23PM -0700, Martin Sebor wrote:
> @@ -1228,24 +1228,30 @@ maybe_diag_overlap (location_t loc, gcall *call, b
>
> if (dstref.offrange[0] == dstref.offrange[1]
> || dstref.offrange[1] > HOST_WIDE_INT_MAX)
> - sprintf (offstr[0], "%lli", (long long) dstref.offrange[0].to_shwi ());
> + sprintf (offstr[0], HOST_WIDE_INT_PRINT_DEC,
> + (long long) dstref.offrange[0].to_shwi ());
to_shwi () returns a HOST_WIDE_INT, there is no point in casting that to
(long long), and in case long long is different from HOST_WIDE_INT it might
result in warnings or even UB. Just drop those casts everywhere where
the operand already is SHWI or UHWI.
Jakub