when compiling avr-libc-1.6.8 there's a compiler ICE due to the __attribute__((progmem)) construct in dtostre.c and vfscanf.c. this construct triggers: gcc_assert (quals == orig_quals || TREE_CODE (argtype) == FUNCTION_TYPE); the argtype in this case is array_type.
Created attachment 20983 [details] pre-processed source
i forgot to mention that if i comment out the assertion the correct code does seem to get generated. since i'm not a gcc internals person, this may just be coincidental.
This is a bug in the AVR back end; if it marks a decl readonly it must also adjust the type of the decl. The problem code is probably in avr_insert_attributes.
thanks for the hint about avr_insert_attribute. there's a comment there mumbling: /* ??? This seems sketchy. Why can't the user declare the thing const in the first place? */ when it sets the node's readonly-ness. if i declare the array to have const elements there's no ICE. i guess the 'fix' is to sprinkle const-goodness around the source although it might be nice to have a slightly nicer error message.
An assertion failure is always a bug. Yes, an error if the object isn't already const would be one valid fix.
Confirmed.
The problem occurs also with avr-libc-1.7.1 with gcc 4.6.0 release.
Author: gjl Date: Thu Apr 14 08:38:20 2011 New Revision: 172415 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172415 Log: PR target/44643 * config/avr/avr.c (avr_insert_attributes): Leave TREE_READONLY alone. Error if non-const data has attribute progmem. Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c
Please note that fixing this bug just reduces the inconvenience from an "internal compiler error" to an ordinary "error" with a more comprehensible message. The very problem is that avr-libc's PSTR macro tries to put the non-const variable __c[] into the read-only section .progmem.data by means of __attribute__((progmem)). Thus, in order to build avr-libc, PSRT has to be fixed. For details please f'up to issue #32988 in avr-libc http://savannah.nongnu.org/bugs/?32988
Cloased as resolved+fixed in 4.7.0
*** Bug 49125 has been marked as a duplicate of this bug. ***
Author: gjl Date: Thu May 26 12:52:03 2011 New Revision: 174281 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174281 Log: PR target/44643 * config/avr/avr.c (avr_insert_attributes): Leave TREE_READONLY alone. Error if non-const data has attribute progmem. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/avr/avr.c
*** Bug 26883 has been marked as a duplicate of this bug. ***
Author: gjl Date: Mon Jul 4 12:28:02 2011 New Revision: 175809 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175809 Log: PR target/44643 * config/avr/avr.c (avr_insert_attributes): Use TYPE_READONLY instead of TREE_READONLY. Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c
Author: gjl Date: Mon Jul 4 12:33:00 2011 New Revision: 175810 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175810 Log: Backport from mainline 2011-07-04 Georg-Johann Lay PR target/44643 * config/avr/avr.c (avr_insert_attributes): Use TYPE_READONLY instead of TREE_READONLY. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/avr/avr.c
Author: gjl Date: Mon Jul 4 12:48:04 2011 New Revision: 175811 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175811 Log: PR target/34734 PR target/44643 * gcc.target/avr/avr.exp: Run over cpp files, too. * gcc.target/avr/torture/avr-torture.exp: Ditto. * gcc.target/avr/progmem.h: New file. * gcc.target/avr/exit-abort.h: New file. * gcc.target/avr/progmem-error-1.c: New file. * gcc.target/avr/progmem-error-1.cpp: New file. * gcc.target/avr/progmem-warning-1.c: New file. * gcc.target/avr/torture/progmem-1.c: New file. * gcc.target/avr/torture/progmem-1.cpp: New file. Added: trunk/gcc/testsuite/gcc.target/avr/exit-abort.h trunk/gcc/testsuite/gcc.target/avr/progmem-error-1.c trunk/gcc/testsuite/gcc.target/avr/progmem-error-1.cpp trunk/gcc/testsuite/gcc.target/avr/progmem-warning-1.c trunk/gcc/testsuite/gcc.target/avr/progmem.h trunk/gcc/testsuite/gcc.target/avr/torture/progmem-1.c trunk/gcc/testsuite/gcc.target/avr/torture/progmem-1.cpp Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.target/avr/avr.exp trunk/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp