[PATCH] support: Add TEST_COMPARE macro

Florian Weimer fweimer@redhat.com
Mon Nov 27 18:43:00 GMT 2017


On 11/27/2017 07:33 PM, Paul Eggert wrote:
> On 11/27/2017 10:06 AM, Florian Weimer wrote:
>> I'm not certain about that at all—the *types* could well differ in 
>> signedness between architectures (as it is common for char). 
> 
> char should not be a problem: on all glibc platforms, it's widened to 
> int before comparison, so its signedness is not relevant to the comparison.

I don't understand.

It is perfectly reasonable to warn for

    ch == EOF

(with ch of type char) because that is always a bug, and for us (who 
strive to write portable code) even if char is signed.

It is not reasonable at all to warn for:

    ch == '\n'
    ch == 0
    ch == '\xff'

Surely the type should feed into the warning, but it can't be the sole 
arbitrator.

Florian



More information about the Libc-alpha mailing list