public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marcos_vc at coel dot com.br" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/50733] New: avr-gcc 4.3.5 generates incorrect code when using PROGMEM macro
Date: Fri, 14 Oct 2011 19:52:00 -0000	[thread overview]
Message-ID: <bug-50733-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50733

             Bug #: 50733
           Summary: avr-gcc 4.3.5 generates incorrect code when using
                    PROGMEM macro
    Classification: Unclassified
           Product: gcc
           Version: 4.3.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marcos_vc@coel.com.br


Created attachment 25505
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25505
Preprocessed file

Hi,

     The compiler is generating incorrect code for the source code below, when
using the PROGMEM macro:

#include <avr/io.h>
#include <avr/pgmspace.h> // PROGMEM
#include <stdio.h>

static PROGMEM const char orig[6] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
static char dest[6];

int main(void) {

    for(;;) {
        unsigned int loop;
        for (loop = 0; loop < sizeof(orig)/sizeof(orig[0]); loop++)
            dest[loop] = orig[loop];
    }
}

    I compiled using the folowing command line:

avr-gcc -I/usr/lib/gcc/avr/4.3.5/include -I/usr/lib/gcc/avr/4.3.5/include-fixed
-I/usr/lib/avr/include -Wall -g3 -gstabs -O0 -fpack-struct -fshort-enums
-std=gnu99 -funsigned-char -funsigned-bitfields -save-temps -Wall -Wextra
-fno-strict-aliasing -fwrapv -mmcu=atmega16 -DF_CPU=1000000UL test.c


    It should have a "lpm" instruction somewhere in the asm output. The result
is "orig" not being copied to "dest".
    The compiler generates correct code when the PROGMEM macro is removed but
it generates a copy of the constant in the SRAM which is undesirable because
I´m using large tables that fills up all the SRAM.

GCC version: 4.3.5
Host type: x86_64-linux-gnu (Ubuntu 11.04)
Target type: avr
Configure command line: ../src/configure -v --enable-languages=c,c++
--prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man
--bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared
--with-system-zlib --enable-long-long --enable-nls --without-included-gettext
--disable-checking --disable-libssp --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=avr


             reply	other threads:[~2011-10-14 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14 19:52 marcos_vc at coel dot com.br [this message]
2011-10-19 11:01 ` [Bug target/50733] " wek at host dot sk
2011-10-19 15:03 ` marcos_vc at coel dot com.br
2011-12-01 12:44 ` eric.weddington at atmel dot com

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=bug-50733-4@http.gcc.gnu.org/bugzilla/ \
    --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).