This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: sign-compare warning for short and char
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Christophe de Dinechin <dinechin at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 20 Feb 2018 15:15:08 +0000
- Subject: Re: sign-compare warning for short and char
- Authentication-results: sourceware.org; auth=none
- References: <50F32C36-4EE5-4375-BAC6-46FCCECE1571@redhat.com>
This question belongs on the gcc-help list really.
On 20 February 2018 at 14:44, Christophe de Dinechin
<dinechin@redhat.com> wrote:
> I wonder why -Wsign-compare only warns when there is no int promotion?
I suspect the correct-but-not-helpful answer is that after integer
promotion the operands have the same type, and so there's no
comparison between signed and unsigned types.
But the compiler could make the warning apply *before* doing integer
promotion, to diagnose this case.