bugmake - Bugs: bug #57930, plain char arguments to...


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

Submitted by:  None
Submitted on:  Sun 01 Mar 2020 01:10:01 PM UTC  
Severity:  3 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  Paul D. Smith <psmith> Open/Closed:  Closed
Component Version:  4.0 Operating System:  None
Fixed Release:  SCM Triage Status:  Small Effort

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 03 May 2020 07:07:00 PM UTC, comment #1: 

Besides the issue in load.c there were only two places where the cast was missing: one in the implementations of strcasecmp / strcasencmp which are only needed on systems that don't provide any case-insensitive comparison natively, and secondly in a bunch of VMS code.  I don't know if VMS even does UTF/Unicode.

I fixed them all anyway; thanks for the note.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Sun 01 Mar 2020 01:10:01 PM UTC, original submission:  

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.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-05-03 psmith StatusNone => Fixed
        Assigned toNone => psmith
        Open/ClosedOpen => Closed
        Component VersionNone => 4.0
        Fixed ReleaseNone => SCM
        Triage StatusNone => Small Effort

    Back to the top

    Powered by Savane 3.5