-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Char subscript error in Cygwin #71
Comments
Hmm... if an integer literal can't be used as an array subscript that really seems like a bug with the compiler rather than the code in question. |
I think you are misreading the warning. isxdigit() takes an integer argument and unitname[0] is a char. This is very deliberately a warning by GCC and llvm. This is from the GCC manual:
The warning should be fixed. |
So, yes, I misread the error as about being the apparent subscripts here rather than the
Yes, we're expecting Fwiw, I always compile with
I'm guessing you mean by making it I'm not thrilled at the prospect of obfuscating the code with an additional cast to work around what's arguably a bug in the library implementation. |
The basic problem is that it is implementation-defined if char is signed or unsigned. See also https://stackoverflow.com/questions/17975913/does-ctype-h-still-require-unsigned-char. I think all the is*(x) calls from ctype.h should be changed to is*((unsigned char)x). |
I'm getting the following error when building in Cygwin
checks.c:1183:52: error: array subscript has type 'char' [-Werror=char-subscripts]
1183 | if (unitname[0] == '0' && isxdigit(unitname[1]))
I guess all that needs to be done is to do a type cast on the '1'?
The text was updated successfully, but these errors were encountered: