Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #155549

Re: Puzzling "array subscript has type char" warning.

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Puzzling "array subscript has type char" warning.
Date 2020-10-11 17:28 -0700
Organization None to speak of
Message-ID <87wnzw5lui.fsf@nosuchdomain.example.com> (permalink)
References <e7Cdncm5EpqKbMfCnZ2dnUU7_83NnZ2d@giganews.com> <87lfhhge1m.fsf@nosuchdomain.example.com> <mlp6ofhh2jdc0ojt7qi6j3os6rr45pniel@4ax.com>

Show all headers | View raw


dave_thompson_2@comcast.net writes:
> On Thu, 10 Sep 2020 20:58:29 -0700, Keith Thompson
> <Keith.S.Thompson+u@gmail.com> wrote:
> ...
>> isdigit is very likely a macro in the implementation you're using.
>> The macro presumably works by subscripting into an array object.
> ...
>> The ctype() function requires an argument of type int whose value must
>> be either EOF (almost certainly -1) or a value representable as an
>> unsigned char.  For any other value, the behavior is undefined.
>> 
>> A typical implementation might define an array of small integers indexed
>> from 0 to UCHAR_MAX+1, with the index value computed by subtracting 1
>> from the argument.
>> 
> ADDING 1 to the argument (which is -1..UCHAR_MAX)

Yes, adding, thanks.

> and then testing a bit, or sometimes a few bits, of the array element
>
> which, more interestingly, is okay because isxx() are only required to
> return nonzero or zero, not specifically one or zero as for the
> builtin comparison/equality and logical operators.
>
> (e-s made me change the subject, sorry)

What is "e-s"?  (The previous subject had a couple of non-ASCII
characters.)

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Puzzling "array subscript has type ‘char’" warning. Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-09-10 20:37 -0700
  Re: Puzzling "array subscript has type ‘char’" warning. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-10 20:58 -0700
    Re: Puzzling "array subscript has type ‘char’" warning. Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-09-10 22:49 -0700
      Re: Puzzling "array subscript has type ‘char’" warning. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-11 01:10 -0700
        Re: Puzzling "array subscript has type ‘char’" warning. gazelle@shell.xmission.com (Kenny McCormack) - 2020-09-11 13:09 +0000
          Re: Puzzling "array subscript has type ‘char’" warning. Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-09-11 06:14 -0700
      Re: Puzzling "array subscript has type ‘char’" warning. Richard Damon <Richard@Damon-Family.org> - 2020-09-11 08:09 -0400
      Re: Puzzling "array subscript has type ‘char’" warning. James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-09-11 09:01 -0400
      Re: Puzzling "array subscript has type ‘char’" warning. Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-11 16:16 +0000
    Re: Puzzling "array subscript has type char" warning. dave_thompson_2@comcast.net - 2020-10-11 16:12 -0400
      Re: Puzzling "array subscript has type char" warning. Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-10-11 17:28 -0700
        Re: Puzzling "array subscript has type char" warning. dave_thompson_2@comcast.net - 2020-11-01 23:07 -0500
  Re: Puzzling "array subscript has type ‘char’" warning. jenniferjeson35@gmail.com - 2020-11-06 20:35 -0800

csiph-web