[Freeciv-Dev] Re: Compiler-warnings
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Wed, Jan 24, 2001 at 10:09:14PM +0100, Stepan Roh wrote:
>
>
> On Wed, 24 Jan 2001, Raimar Falke wrote:
>
> > gcc -Wall gives:
> > a.c: In function `main':
> > a.c:10: warning: array subscript has type `char'
> >
> > So it looks like gcc will accept signed or unsigned char as array
> > subscripts. It can also be done using int. Both solution will silence
> > the warning but maybe there is also something else to consider.
>
> There is a gcc option -Wchar-subscripts (citation from info docs
> follows), which is enabled with -Wall (and can be disabled with
> -Wno-char-subscripts).
I know. I looked at the code:
$ grep -n isal stdinhand.c
1957: for(cptr_s=str; *cptr_s && !isalnum(*cptr_s); cptr_s++);
1960: for(cptr_d=arg_level; *cptr_s && isalnum(*cptr_s); cptr_s++, cptr_d++) {
2000: for(; *cptr_s && !isalnum(*cptr_s); cptr_s++);
2004: *cptr_s && (*cptr_s == '-' || *cptr_s == ' ' || isalnum(*cptr_s));
2224: for(cptr_s=str; *cptr_s && !isalnum(*cptr_s); cptr_s++);
2225: for(cptr_d=command; *cptr_s && isalnum(*cptr_s); cptr_s++, cptr_d++)
2368: for(cptr_s=str; *cptr_s && !isalnum(*cptr_s); cptr_s++);
2369: for(cptr_d=command; *cptr_s && isalnum(*cptr_s); cptr_s++, cptr_d++)
2451: return isalnum(c);
2459: return (c == '-') || (c == '*') || (c == '+') || (c == '=') ||
isalnum(c);
2598: for(cptr_s=str; *cptr_s && !isalnum(*cptr_s); cptr_s++);
2600: for(cptr_d=command; *cptr_s && isalnum(*cptr_s) &&
3334: while (str_itr < rl_line_buffer + start && !isalnum(*str_itr))
3341: if (isalnum(*str_itr)) /* not a distinct word */
3346: if (isalnum(*str_itr))
3366: if (isalnum(*str_itr))
3395: if (isalnum(*chptr)) {
So isalnum() is a macro which uses arrays and the compiler gives
warnings. Quoting from glibc's ctype.h:
These point into arrays of 384, so they can be indexed by any `unsigned
char' value [0,255]; by EOF (-1); or by any `signed char' value
[-128,-1). ISO C requires that the ctype functions work for `unsigned
char' values and for EOF; we also support negative `signed char' values
for broken old programs. The case conversion arrays are of `int's
rather than `unsigned char's because tolower (EOF) must be EOF, which
So isalnum() works only for unsigned char on all platforms.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Make it idiot-proof and someone will make a better idiot."
- [Freeciv-Dev] Compiler-warnings, Gerhard Killesreiter, 2001/01/23
- [Freeciv-Dev] Re: Compiler-warnings, Falk Hueffner, 2001/01/23
- [Freeciv-Dev] Re: Compiler-warnings, Gerhard Killesreiter, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Dirk Stoecker, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Gerhard Killesreiter, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Raimar Falke, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Gerhard Killesreiter, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Raimar Falke, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Stepan Roh, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings,
Raimar Falke <=
- [Freeciv-Dev] Re: Compiler-warnings, Tony Stuckey, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Stepan Roh, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Raimar Falke, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Falk Hueffner, 2001/01/24
- [Freeciv-Dev] Re: Compiler-warnings, Dirk Stoecker, 2001/01/25
[Freeciv-Dev] Re: Compiler-warnings, Reinier Post, 2001/01/24
[Freeciv-Dev] Re: Compiler-warnings, Dirk Stoecker, 2001/01/24
|
|