Bug 44643 - [4.6 Regression][avr] ICE in c-typeck.c
[4.6 Regression][avr] ICE in c-typeck.c
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
4.6.0
: P3 normal
: 4.6.2
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
: 26883 49125 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-23 03:20 UTC by d p chang
Modified: 2011-10-26 19:54 UTC (History)
7 users (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.6.2, 4.7.0
Known to fail: 4.6.0
Last reconfirmed: 2010-06-28 01:06:26


Attachments
pre-processed source (10.40 KB, text/plain)
2010-06-23 03:21 UTC, d p chang
Details

Note You need to log in before you can comment on or make changes to this bug.
Description d p chang 2010-06-23 03:20:46 UTC
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.
Comment 1 d p chang 2010-06-23 03:21:56 UTC
Created attachment 20983 [details]
pre-processed source
Comment 2 d p chang 2010-06-23 03:22:58 UTC
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.
Comment 3 Joseph S. Myers 2010-06-23 11:07:08 UTC
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.
Comment 4 d p chang 2010-06-23 15:59:43 UTC
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.
Comment 5 Joseph S. Myers 2010-06-23 16:35:19 UTC
An assertion failure is always a bug.  Yes, an error if the object
isn't already const would be one valid fix.
Comment 6 Andrew Pinski 2010-06-28 01:06:26 UTC
Confirmed.
Comment 7 Klaus Rudolph 2011-03-31 07:53:25 UTC
The problem occurs also with avr-libc-1.7.1 with gcc 4.6.0 release.
Comment 8 Georg-Johann Lay 2011-04-14 08:38:29 UTC
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
Comment 9 Georg-Johann Lay 2011-04-14 15:10:48 UTC
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
Comment 10 Georg-Johann Lay 2011-04-14 15:29:37 UTC
Cloased as resolved+fixed in 4.7.0
Comment 11 Joseph S. Myers 2011-05-23 16:30:47 UTC
*** Bug 49125 has been marked as a duplicate of this bug. ***
Comment 12 Georg-Johann Lay 2011-05-26 12:52:10 UTC
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
Comment 13 Georg-Johann Lay 2011-06-16 17:24:03 UTC
*** Bug 26883 has been marked as a duplicate of this bug. ***
Comment 14 Georg-Johann Lay 2011-07-04 12:28:05 UTC
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
Comment 15 Georg-Johann Lay 2011-07-04 12:33:03 UTC
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
Comment 16 Georg-Johann Lay 2011-07-04 12:48:07 UTC
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