This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] [C] Warn when calculating abs(unsigned_value)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Martin Jambor <mjambor at suse dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Aug 2018 16:49:57 +0000
- Subject: Re: [PATCH] [C] Warn when calculating abs(unsigned_value)
- References: <email@example.com> <firstname.lastname@example.org>
On Wed, 15 Aug 2018, Martin Sebor wrote:
> Detecting some of these bugs without too much noise would require
> moving the warning out of the front-end and to some later point
> after VRP has run.
But you need the information about whether the conversion was explicit or
implicit. If someone does
abs ((int) unsigned_var)
it's presumably intentional and should not receive a warning. If they do
it's suspect. If they do
it's entirely possible they know the long value is within range for int,
but it came from some API that produces long.
Joseph S. Myers