Comments (4)
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.
from dtc.
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:
-Wchar-subscripts
Warn if an array subscript has type char. This is a common cause of error, as programmers often forget that this type is signed on some machines. This warning is enabled by -Wall.
The warning should be fixed.
from dtc.
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:
So, yes, I misread the error as about being the apparent subscripts here rather than the isxdigit()
call, but the description of the error still doesn't make the problem apparent.
-Wchar-subscripts
Warn if an array subscript has type char. This is a common cause of error, as programmers often forget that this type is signed on some machines. This warning is enabled by -Wall.
Yes, we're expecting unitname[1]
to be promoted to int as a parameter to the function isxdigit()
, but that doesn't really have anything to do with array subscripts. My best guess here is that the Cygwin isxdigit()
is implemented as a macro. If that macro is then indexing a lookup table using the parameter, that would explain this error. If that's the case, I really think that's a bug in the isxdigit()
implementation, rather than the code in dtc - although it takes an int for (borderline archaic) technical reasons, isxdigit()
is explicitly about testing characters, it seems pretty bogus for it not to be ok to pass a char
value to it.
Fwiw, I always compile with -Wall
on Linux and I've never seen this error, nor do I see it if I explicitly add -Wchar-subscripts
.
The warning should be fixed.
I'm guessing you mean by making it isxdigit((int)unitname[1])
?
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.
from dtc.
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).
from dtc.
Related Issues (20)
- Multiple-definition of fdt target in Meson definitions HOT 6
- unit_address_vs_reg: Wrong warning for /memory node HOT 3
- fdt.c crashes at absoffset = offset + fdt_off_dt_struct(fdt); HOT 6
- how can I download the archive inside debootstrap environment HOT 3
- `testCreate`/`testReserveMap` fails with Python 3.12 HOT 12
- python extension build with meson is always quiet HOT 2
- python extension rebuilt during meson's install phase HOT 6
- Improve dtdiff by avoiding or nulling the phandles HOT 11
- 0xFFFFFFFF00000000 parsed as 32 bit HOT 5
- New release planned? HOT 8
- last commit breaks building the Python bindings HOT 2
- pylibfdt bindings cryptically fail to build with some build environments HOT 3
- Enabling -Wwrite-strings causes a number of warnings HOT 2
- README.md has no instructions for building with meson HOT 2
- Meson tests fail HOT 3
- 1.7.0-Testsuite-Error HOT 1
- 'struct fdt_header' has no member named [name] HOT 2
- 1.7.0: install target fails on HOT 10
- Apply multiple DTB overlays to create single DTB file? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dtc.