This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13427] New: PGM string doesn't properly with strcpy variable index array
- From: "ken at realtronix dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Dec 2003 06:39:45 -0000
- Subject: [Bug c/13427] New: PGM string doesn't properly with strcpy variable index array
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <string.h>
const char foo[] PROGMEM = "foo";
const char bar[] PROGMEM = "bar";
PGM_P Langs[2] PROGMEM = {foo, bar};
int main(void)
{
unsigned char i;
char buf[2][5];
//strcpy_P works fine with constant index
strcpy_P(buf[0], Langs[0]); //correctly copy 'foo'
strcpy_P(buf[1], Langs[1]); //correctly copy 'bar'
//but strcpy_P copy char from wrong address if use variable indexing
for (i=0; i<2; i++)
strcpy_P(buf[i], Langs[i]); //copy garbages!!!
return 1;
}
--
Summary: PGM string doesn't properly with strcpy variable index
array
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ken at realtronix dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13427