This is fix of PR44643 which is triggerd by http://savannah.nongnu.org/bugs/?32988
i.e. include/avr/pgmspace.h:PSTR has to be changed, too: PSTR has to generate __c as "static const char[]", not as "static char[]". Note that avr-libc has to be changed anyway, no matter if or if not this patch is applied or not. 2011-04-07 Georg-Johann Lay <a...@gjlay.de> PR target/44643 * config/avr/avr.c (avr_insert_attributes): Error if non-const data has attribute progmem.
Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (Revision 172046) +++ config/avr/avr.c (Arbeitskopie) @@ -5149,14 +5149,20 @@ avr_insert_attributes (tree node, tree * && (TREE_STATIC (node) || DECL_EXTERNAL (node)) && avr_progmem_p (node, *attributes)) { - static const char dsec[] = ".progmem.data"; - *attributes = tree_cons (get_identifier ("section"), - build_tree_list (NULL, build_string (strlen (dsec), dsec)), - *attributes); + if (TREE_READONLY (node)) + { + static const char dsec[] = ".progmem.data"; - /* ??? This seems sketchy. Why can't the user declare the - thing const in the first place? */ - TREE_READONLY (node) = 1; + *attributes = tree_cons (get_identifier ("section"), + build_tree_list (NULL, build_string (strlen (dsec), dsec)), + *attributes); + } + else + { + error ("variable %q+D must be const in order to be put into" + " read-only section by means of %<__attribute__((progmem))%>", + node); + } } }