Summary: | [4.2/4.3/4.5/4.6 Regression][avr] attribute((progmem)) not handled properly in C++ | ||
---|---|---|---|
Product: | gcc | Reporter: | Markus Lampert <markuslampert> |
Component: | target | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | Alan.Burlison, dlyons, eric.weddington, gcc-bugs, gjl, hsteinhaus, ilgb, Kicer86, mschulze, niki.waibel, sb-sf |
Priority: | P3 | Keywords: | diagnostic |
Version: | 4.2.2 | ||
Target Milestone: | 4.6.2 | ||
Host: | x86 | Target: | avr |
Build: | Known to work: | 4.6.2 | |
Known to fail: | 4.2.1, 4.2.2, 4.3.2, 4.6.1 | Last reconfirmed: | 2009-08-07 19:18:06 |
Description
Markus Lampert
2008-01-11 01:23:27 UTC
after upgrading to WinAVR-20071221 my C++ projects trigger the same warning message. for completeness, my sources look like: // usb_user_device_descriptor PROGMEM S_usb_device_descriptor usb_dev_desc = { sizeof( usb_dev_desc ), DEVICE_DESCRIPTOR, U_WORD( USB_SPECIFICATION ), DEVICE_CLASS, DEVICE_SUB_CLASS, DEVICE_PROTOCOL, EP_CONTROL_LENGTH, U_WORD( VENDOR_ID ), U_WORD( PRODUCT_ID ), U_WORD( RELEASE_NUMBER ), STRING_INDEX_MAN, STRING_INDEX_PROD, STRING_INDEX_SN, NB_CONFIGURATION }; Liviu version 4.2.1 seems to be affected as well: -------------------------------------------- holger@x:~/scratch$ cat foo.cpp #include <avr/pgmspace.h> const int foobar1 = 42; int foobar2 = 42; const int PROGMEM foobar3 = 42; int PROGMEM foobar4 = 42; holger@x:~/scratch$ avr-g++ -Wall -mmcu=atmega1281 -c foo.cpp foo.cpp:5: warning: only initialized variables can be placed into program memory area foo.cpp:6: warning: only initialized variables can be placed into program memory area holger@x:~/scratch$ avr-g++ --version avr-g++ (GCC) 4.2.1 (SUSE Linux) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *** Bug 40112 has been marked as a duplicate of this bug. *** I found a way to place data in program memory for C++ without producing the annoying warnings. The trick is omiting __attribute__((__progmem__)) and instead always use __attribute__((section(".progmem.something"))) for placing your data into a special section beginning with ".progmem.". I tested this with different avr-g++ compiler versions (3.4.4, 4.1.1, 4.2.1, 4.3.3, 4.4.0, and 4.4.3), and it always results in the desired behavior. Example: [mschulze@teeth tst]$ cat progmem.cpp static char __attribute((section(".progmem.something"))) str[]="program memory data"; const char* test() { return str; } [mschulze@teeth tst]$ /usr/bin/avr-g++ -Wall -mmcu=atmega1281 -c progmem.cpp [mschulze@teeth tst]$ /usr/bin/avr-g++ --version avr-g++ (GCC) 4.3.3 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [mschulze@teeth tst]$ Regards, Michael same problem in 4.5.2. Maybe importance of this bug should be increased? Imho it's a little bit embarrassing to keep this bug so long... (since 2008, over 3 yrs!) regards Author: gjl Date: Wed Jun 29 07:57:25 2011 New Revision: 175621 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175621 Log: PR target/34734 * config/avr/avr.c (avr_handle_progmem_attribute): Move warning about uninitialized data attributed 'progmem' from here... (avr_encode_section_info): ...to this new function. (TARGET_ENCODE_SECTION_INFO): New define. (avr_section_type_flags): For data in ".progmem.data", remove section flag SECTION_WRITE. Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c Author: gjl Date: Thu Jun 30 13:28:43 2011 New Revision: 175705 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175705 Log: PR target/34734 Backport from mainline * config/avr/avr.c (avr_handle_progmem_attribute): Move warning about uninitialized data attributed 'progmem' from here... (avr_encode_section_info): ...to this new function. (TARGET_ENCODE_SECTION_INFO): New define. (avr_section_type_flags): For data in ".progmem.data", remove section flag SECTION_WRITE. Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/avr/avr.c Closed as resolved+fixed. (In reply to comment #5) > same problem in 4.5.2. > Maybe importance of this bug should be increased? Imho it's a little bit > embarrassing to keep this bug so long... (since 2008, over 3 yrs!) > regards Increasing importance won't help. The only thing that would help is increasing number of people that are inclined to improve avr-gcc. regards Note that progmem on types is not documented an not supposed to work at all. Author: gjl Date: Thu Jun 30 13:45:04 2011 New Revision: 175706 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175706 Log: PR target/34734 Backport from mainline (avr_section_type_flags): For data in ".progmem.data", remove section flag SECTION_WRITE. 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 *** Bug 260998 has been marked as a duplicate of this bug. *** Seen from the domain http://volichat.com Marked for reference. Resolved as fixed @bugzilla. |