[Bug c/13428] New: gcc-avr doesn't work properly with PGM string
ken at realtronix dot net
gcc-bugzilla@gcc.gnu.org
Thu Dec 18 06:47:00 GMT 2003
gcc version as:
Configured with: ../configure --prefix=/e/avrdev/install --target=avr --enable-
languages=c,c++ --disable-nls --enable-win32-registry=WinAVR
Thread model: single
gcc version 3.3.1
demo program as:
#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: gcc-avr doesn't work properly with PGM string
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=13428
More information about the Gcc-bugs
mailing list