Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd4ba4c

Browse filesBrowse files
authored
Fix pgm_read_ptr in AVR pgmspace.h
Originally, `pgm_read_ptr` used to cast its argument to `const void *`, i.e. a pointer to read-only data. This is incorrect, because the argument is a pointer to a pointer in "flash memory". You cannot cast it to `const void *` and then dereference it, because `void` is not an object type. Also, the pointer itself is read-only, but the data could in theory be mutable. The correct type should be `void *const *`, i.e. a pointer to a read-only pointer to any data.
1 parent 45e4e5a commit cd4ba4c
Copy full SHA for cd4ba4c

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

‎api/deprecated-avr-comp/avr/pgmspace.h

Copy file name to clipboardExpand all lines: api/deprecated-avr-comp/avr/pgmspace.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef const void* uint_farptr_t;
103103
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
104104
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
105105
#define pgm_read_float(addr) (*(const float *)(addr))
106-
#define pgm_read_ptr(addr) (*(const void *)(addr))
106+
#define pgm_read_ptr(addr) (*(void *const *)(addr))
107107

108108
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
109109
#define pgm_read_word_near(addr) pgm_read_word(addr)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.