bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #57930] plain char arguments to <ctype.h> functions


From: anonymous
Subject: [bug #57930] plain char arguments to <ctype.h> functions
Date: Sun, 1 Mar 2020 08:10:04 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0

URL:
  <https://savannah.gnu.org/bugs/?57930>

                 Summary: plain char arguments to <ctype.h> functions
                 Project: make
            Submitted by: None
            Submitted on: Sun 01 Mar 2020 01:10:01 PM UTC
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: None
        Operating System: None
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

Building git head currently fails because of an ancient sin: passing plain
char arguments to functions from <ctype.h>.  E.g. this happens on Cygwin with
GCC 9.2:

  CC       src/load.o
In file included from src/makeint.h:75,
                 from src/load.c:17:
src/load.c: In function 'load_file':
src/load.c:198:23: error: array subscript has type 'char'
[-Werror=char-subscripts]
  198 |       while (isalnum (*fp) || *fp == '_')
      |                       ^~~
cc1: all warnings being treated as errors

The argument to these function/macros is formally an int, holding either a
value from the range of unsigned char, or EOF.  Plain char might be signed,
which is unsuitable for this usage.

So everywhere a plain char is passed to isalpha(), isspace() etc., it has to
be cast to (unsigned char) first.

Please note that the above is not the only one in the source that is wrong in
this regard.  It's just the only one active in this particular build.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57930>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]