Bug 51756 - wrong warning: uninitialized variable put into program memory area
Summary: wrong warning: uninitialized variable put into program memory area
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P5 minor
Target Milestone: 4.6.3
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2012-01-04 21:28 UTC by Georg-Johann Lay
Modified: 2012-01-12 17:24 UTC (History)
2 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2012-01-04 21:28:12 UTC
The following test case produces a false warning:

char foo (void)
{
    extern const __pgm char v[];
    return v[0];
}

$ avr-gcc -c foo.c -Wall
foo.c: In function 'foo':
foo.c:3:29: warning: uninitialized variable 'v' put into program memory area [-Wuninitialized]



avr_encode_section_info should test for DECL_EXTERNAL.
Comment 1 Georg-Johann Lay 2012-01-04 21:54:04 UTC
The following code also triggers the false warning for 4.6.2:

extern const char v[] __attribute__((progmem));
char foo (void)
{
    return v[0];
}
Comment 2 Georg-Johann Lay 2012-01-12 16:51:44 UTC
Author: gjl
Date: Thu Jan 12 16:51:28 2012
New Revision: 183129

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183129
Log:
	PR target/51756
	* config/avr/avr.c (avr_encode_section_info): Test for absence of
	DECL_EXTERNAL when checking for initializers of progmem variables.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c
Comment 3 Georg-Johann Lay 2012-01-12 17:23:38 UTC
Author: gjl
Date: Thu Jan 12 17:23:32 2012
New Revision: 183131

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183131
Log:
	Backport from mainline r183129
	PR target/51756
	* config/avr/avr.c (avr_encode_section_info): Test for absence of
	DECL_EXTERNAL when checking for initializers of progmem variables.


Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/avr/avr.c
Comment 4 Georg-Johann Lay 2012-01-12 17:24:51 UTC
Closed for the milestone