sign-compare warning for short and char
Christophe de Dinechin
dinechin@redhat.com
Tue Feb 20 15:43:00 GMT 2018
> On 20 Feb 2018, at 16:15, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> This question belongs on the gcc-help list really.
I posted here because I saw it as a possible diagnostic bug / limitation. Do such things go to gcc-help? Or is it that you thought I was asking for the correct option?
> 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.
That’s an implementation explanation, not a rationale, right?
> But the compiler could make the warning apply *before* doing integer
> promotion, to diagnose this case.
That is what I am thinking, but I was wondering if there was not some rationale making this a bad idea.
More information about the Gcc
mailing list