Re: patch: signed char issues

From: Jamie Lokier (
Date: Mon Apr 24 2000 - 07:16:29 EST

Russell King wrote:
> I think you've misunderstood the patch. The problem is that:
> char wibble = -1;
> ...
> if (wibble == -1)
> printk("wibble is -1\n");
> else
> printk("wibble is not -1\n");
> will always print "wibble is not -1" on a native unsigned char machine.
> This is a bug, which occurs very often when people don't keep their wits
> about them when using "char" to represent signed numbers. Philip's patch
> solves those discovered in the kernel thus far.
> Unfortunately, people forget about signed-ness issues. I actually wish
> that GCC would warn more about this type of unportable code. (eg,
> detecting an assignment or test between a bare "char" type and a
> negative number).

I suggest you write to <> describing the warning you'd
like to see implemented. Probably nobody thought of adding it until

You might consider including assumptions about bare bitfields too, whose
signedness can vary between machines.

-- Jamie

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:07 EST