public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/13428] New: gcc-avr doesn't work properly with PGM string
@ 2003-12-18  6:47 ken at realtronix dot net
  2003-12-18  8:04 ` [Bug c/13428] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ken at realtronix dot net @ 2003-12-18  6:47 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-12-25 15:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-18  6:47 [Bug c/13428] New: gcc-avr doesn't work properly with PGM string ken at realtronix dot net
2003-12-18  8:04 ` [Bug c/13428] " pinskia at gcc dot gnu dot org
2003-12-19 14:55 ` pinskia at gcc dot gnu dot org
2003-12-20  3:26 ` ken at realtronix dot net
2003-12-20  3:51 ` pinskia at gcc dot gnu dot org
2003-12-20  4:00 ` pinskia at gcc dot gnu dot org
2003-12-24 21:16 ` [Bug c/13428] gcc-avr doesn't work properly with __attribute__((__progmem__)) kazu at cs dot umass dot edu
2003-12-24 22:43 ` [Bug c/13428] gcc-avr doesn't work non-constant array references pinskia at gcc dot gnu dot org
2003-12-25 10:01 ` ken at realtronix dot net
2003-12-25 12:03 ` ken at realtronix dot net
2003-12-25 16:11 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).