NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/58912: ctype(3) abuse detection fails for variable references
>Number: 58912
>Category: lib
>Synopsis: ctype(3) abuse detection fails for variable references
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 18 01:55:00 +0000 2024
>Originator: Taylor R Campbell
>Release: current, 10, 9?
>Organization:
The isnetbsd Foundation
>Environment:
>Description:
The ctype(3) abuse detection trick with -Wchar-subscripts works when the input is an array element, pointer dereference, or function call, but not when it's a variable reference:
$ cat foo.c
#include <ctype.h>
extern char x;
int f(void) { return isspace(x); }
$ cat bar.c
#include <ctype.h>
extern char x[];
int f(void) { return isspace(x[0]); }
$ cc -c -Wall -Werror foo.c
$ cc -c -Wall -Werror bar.c
In file included from /usr/include/ctype.h:100,
from bar.c:1:
bar.c: In function 'f':
bar.c:3:31: error: array subscript has type 'char' [-Werror=char-subscripts]
3 | int f(void) { return isspace(x[0]); }
| ^
cc1: all warnings being treated as errors
Expected both cc invocations to report warning.
>How-To-Repeat:
>Fix:
Yes, please!
Putting
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-Wsystem-headers"
...
#pragma GCC diagnostic pop
around the definitions in sys/ctype_inline.h may work but may also have side effects I haven't thought of yet.
Home |
Main Index |
Thread Index |
Old Index