public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ken at realtronix dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/13428] New: gcc-avr doesn't work properly with PGM string
Date: Thu, 18 Dec 2003 06:47:00 -0000	[thread overview]
Message-ID: <20031218064547.13428.ken@realtronix.net> (raw)

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


             reply	other threads:[~2003-12-18  6:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-18  6:47 ken at realtronix dot net [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031218064547.13428.ken@realtronix.net \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).