ArduinoCore-sam icon indicating copy to clipboard operation
ArduinoCore-sam copied to clipboard

Incorrect const in pgm_read_ptr

Open tttapa opened this issue 5 years ago • 0 comments

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: https://github.com/tttapa/Control-Surface/issues/64

tttapa avatar Nov 23 '19 19:11 tttapa