I think it means array ELEMENT, not subscript, has type char.

(Also, once upon a time char widened to int...)

John 

    On Thursday, 26 March 2020, 21:23:41 GMT, Åke Rehnman 
<[email protected]> wrote:  
 
 Hello all,

newlib forces parameter c to isalnum(c) to be unsigned char or int.

BR

/Ake

In file included from ../src/helper/system.h:29,
                  from ./config.h:338,
                  from ../src/flash/nor/nrf5.c:22:
../src/flash/nor/nrf5.c: In function ‘nrf5_info_variant_to_str’:
../src/flash/nor/nrf5.c:575:16: error: array subscript has type ‘char’ 
[-Werror=char-subscripts]
   575 |  if (isalnum(bf[0]) && isalnum(bf[1]) && isalnum(bf[2]) && 
isalnum(bf[3]))
       |              ~~^~~
../src/flash/nor/nrf5.c:575:34: error: array subscript has type ‘char’ 
[-Werror=char-subscripts]
   575 |  if (isalnum(bf[0]) && isalnum(bf[1]) && isalnum(bf[2]) && 
isalnum(bf[3]))
       |                                ~~^~~
../src/flash/nor/nrf5.c:575:52: error: array subscript has type ‘char’ 
[-Werror=char-subscripts]
   575 |  if (isalnum(bf[0]) && isalnum(bf[1]) && isalnum(bf[2]) && 
isalnum(bf[3]))
       |                                                  ~~^~~
../src/flash/nor/nrf5.c:575:70: error: array subscript has type ‘char’ 
[-Werror=char-subscripts]
   575 |  if (isalnum(bf[0]) && isalnum(bf[1]) && isalnum(bf[2]) && 
isalnum(bf[3]))
| ~~^~~

from ctype.h:

/* These macros are intentionally written in a manner that will trigger
    a gcc -Wall warning if the user mistakenly passes a 'char' instead
    of an int containing an 'unsigned char'.  Note that the sizeof will
    always be 1, which is what we want for mapping EOF to __CTYPE_PTR[0];
    the use of a raw index inside the sizeof triggers the gcc warning if
    __c was of type char, and sizeof masks side effects of the extra __c.
    Meanwhile, the real index to __CTYPE_PTR+1 must be cast to int,
    since isalpha(0x100000001LL) must equal isalpha(1), rather than being
    an out-of-bounds reference on a 64-bit machine.  */




_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel
  
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to