[Bug c/38423] New: [avr] function pointers in program memory have wrong addresses
k dot kosciuszkiewicz+gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 6 02:47:00 GMT 2008
Addresses of functions stored in flash memory are stored as word addresses, not
byte addresses.
Test case:
#include <avr/pgmspace.h>
int main(void) {
while (1);
}
int (*ptr) (void) PROGMEM = main;
Build options: -Os -mmcu=attiny13
Fragments of generated code:
Disassembly of section .text:
00000014 <ptr>:
14: 25 00 %.
0000004a <main>:
4a: ff cf rjmp .-2 ; 0x4a <main>
It can be seen that 0x25 * 2 = 0x4a.
--
Summary: [avr] function pointers in program memory have wrong
addresses
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: k dot kosciuszkiewicz+gcc at gmail dot com
GCC host triplet: x86-linux-gnu
GCC target triplet: avr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38423
More information about the Gcc-bugs
mailing list