arduino / arduino/ArduinoCore-sam
Incorrect const in pgm_read_ptr
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
There seems to be bug in macro `pgm_read_ptr` macro in the `pgmspace.h` header.
https://github.com/arduino/ArduinoCore-sam/blob/c893c62ec9953ed36a256b5243272fda2e473c14/cores/arduino/avr/pgmspace.h#L106
The cast to `const void **` is incorrect, because it casts it to _"a pointer to a pointer to a **read-only object** of any type"_.
I believe that the correct type would be `void *const *`, _"a pointer to a **read-only pointer** to an object of any type"_. The pointer itself is in progmem, and therefore is read-only, but the pointee is not necessarily read-only, as it could be in static memory.
Discovered here:
Contributor guide
No contributing guide indexed for this repository
Research direction
Open cores/arduino/avr/pgmspace.h at the linked line and inspect the pgm_read_ptr macro and its callers. Verify the pointer-qualification behavior and compile the affected uses; the issue is done when the cast matches the intended read-only pointer semantics without breaking those uses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100