This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/38423] New: [avr] function pointers in program memory have wrong addresses


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]