Subject: Re: gcc-current and warnings in bin/sh
To: None <tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-userlevel
Date: 05/31/2002 17:18:31
In article <E17DpXi-0005ZP-00@chiark.greenend.org.uk>,
Ben Harris <bjh21@netbsd.org> wrote:
>In article <20020531082910.R523@dr-evil.shagadelic.org> you write:
>>Without the following patch, gcc-current issues the following warnings
>>when building bin/sh (-Werror turned off to demonstrate):
>[...]
>>/u1/netbsd/src/bin/sh/eval.c:641: warning: comparison is always true
>due to limited range of data type
>>/u1/netbsd/src/bin/sh/eval.c:644: warning: comparison is always true
>due to limited range of data type
>[...]
>>I'm not entirely convinced that the patch is correct... definitely want
>>comments...
>
>Hmm.  The problem seems to centre around code like:
>
>        char *p = <thing>;
>        if (is_name(*p)) {
>
>Now, is_name is defined as:
>#define is_name(c)      ((c) != UPEOF && ((c) < CTLESC || (c) > CTLENDARI)
>&& (
>
>where, on a system with unsigned chars:
>#define UPEOF ((unsigned char) -1)
>#define CTLESC '\201'
>#define CTLENDARI '\207'
>                                                                 
>On a system with signed chars, I think UPEOF will end up being just -1.
>
>In either case, I don't think any of those comparisons is "always true", so
>I'm confused.

for systems with signed chars
this ended up being

#define UPEOF -129

which is out of range for char. (it has been fixed)

christos