I´m having troubles understand a compiler warning that we have in our code. The code we have are similar to the one in this example that give the warning (-Wchar-subscripts). We are using ARM gcc 9.2.1 embedded and newlib as standard library.
#include <ctype.h>
int main ()
{
char str[]="Example string\n";
int i = isspace(str[1]); // Warning
char c=str[1];
i = isspace(c); // No warning
i = isspace((unsigned char)str[1]); // No warning
}
From what I have understood the implementation of isspace can be via array indexing. Hence the warning. But in that case shouldn't both 1 and 2 give the warning? Why is it only the first one that gives the warning?
We solved our code by adding a cast but I'm not really satisfied until I have understood why it helps.