Current-Users archive

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

Re: ctype and gcc9



On Mon, Sep 21, 2020 at 09:32:08AM +0100, Patrick Welche wrote:
> Since gcc9, essentially every ctype using piece of software fails with
> 
>    error: array subscript has type 'char' [-Werror=char-subscripts]
> 
> which prompts a style question: cast every argument of every call to
> a ctype function in every piece of software to (unsigned char), or
> -Wno-error=char-subscripts], or something else?

man ctype ... and search for CAVEATS:

     Because the bugs may manifest as silent misbehavior or as crashes only
     when fed input outside the US-ASCII range, the NetBSD implementation of
     the ctype functions is designed to elicit a compiler warning for code
     that passes inputs of type char in order to flag code that may pass
     negative values at runtime that would lead to undefined behavior:


Martin


Home | Main Index | Thread Index | Old Index