Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 34734
Product:  
Component:  
Status: NEW
Resolution:
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Markus Lampert <markuslampert@yahoo.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 34734 depends on: Show dependency tree
Show dependency graph
Bug 34734 blocks:

Additional Comments:





Mark bug as waiting for feedback
Mark bug as suspended




View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2009-08-07 19:18 Opened: 2008-01-11 01:23
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.

------- Comment #1 From Liviu Ionescu 2008-02-02 08:11 -------
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

------- Comment #2 From hsteinhaus@gmx.de 2008-03-07 20:59 -------
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.

------- Comment #3 From Eric Weddington 2009-08-07 19:16 -------
*** Bug 40112 has been marked as a duplicate of this bug. ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug