Using the progmem attribute in C++ sources produce warning messages about uninitialized variables. The following preprocessor output works correctly under 4.1 but produces said warnings (in every warning level):
# 1 "is.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "is.cpp" int i1 __attribute__((__progmem__)) = 1; int __attribute__((__progmem__)) i2 = 2; __attribute__((__progmem__)) int i3 = 3; extern int i4 __attribute__((__progmem__)); int i4 = 4; extern int __attribute__((__progmem__)) i5; int i5 = 5; extern __attribute__((__progmem__)) int i6; int i6 = 6; typedef int i7_t __attribute__((__progmem__)); i7_t i7 = 7; typedef int __attribute__((__progmem__)) i8_t; i8_t i8 = 8; typedef __attribute__((__progmem__)) int i9_t; i9_t i9 = 9; const char s1[] __attribute__((__progmem__)) = "string 1"; const char __attribute__((__progmem__)) s2[] = "string 2"; const __attribute__((__progmem__)) char s3[] = "string 3"; __attribute__((__progmem__)) const char s4[] = "string 4"; extern const char s5[] __attribute__((__progmem__)); const char s5[] = "string 5"; extern const char __attribute__((__progmem__)) s6[]; const char s6[] = "string 6"; extern const __attribute__((__progmem__)) char s7[]; const char s7[] = "string 7"; extern __attribute__((__progmem__)) const char s8[]; const char s8[] = "string 8"; typedef const char s9_t __attribute__((__progmem__)); const s9_t s9[] = "string 9"; typedef const char __attribute__((__progmem__)) s10_t; const s10_t s10[] = "string 10"; typedef const __attribute__((__progmem__)) char s11_t; const s11_t s11[] = "string 11"; typedef __attribute__((__progmem__)) const char s12_t; const s12_t s12[] = "string 12"; This is the used command line and the compiler output: /usr/local/avr-4.2.2/bin/avr-gcc -Wall -save-temps -mmcu=atmega88 -Os -c -o /tmp/x.o is.cpp is.cpp:1: warning: only initialized variables can be placed into program memory area is.cpp:2: warning: only initialized variables can be placed into program memory area is.cpp:3: warning: only initialized variables can be placed into program memory area is.cpp:10: warning: only initialized variables can be placed into program memory area is.cpp:11: warning: only initialized variables can be placed into program memory area is.cpp:12: warning: only initialized variables can be placed into program memory area is.cpp:13: warning: only initialized variables can be placed into program memory area Please note that the same source compiled as C works properly without any warnings. -- Summary: attribute((progmem)) not handled properly in C++ for AVRs Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: markuslampert at yahoo dot com GCC host triplet: x86 GCC target triplet: avr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734