From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15582 invoked by alias); 14 Oct 2011 19:52:29 -0000 Received: (qmail 15573 invoked by uid 22791); 14 Oct 2011 19:52:28 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_XF X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Oct 2011 19:52:14 +0000 From: "marcos_vc at coel dot com.br" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marcos_vc at coel dot com.br X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg01423.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D50733 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=3D25505 Preprocessed file Hi, The compiler is generating incorrect code for the source code below, w= hen using the PROGMEM macro: #include #include // PROGMEM #include static PROGMEM const char orig[6] =3D { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff = }; static char dest[6]; int main(void) { for(;;) { unsigned int loop; for (loop =3D 0; loop < sizeof(orig)/sizeof(orig[0]); loop++) dest[loop] =3D 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-f= ixed -I/usr/lib/avr/include -Wall -g3 -gstabs -O0 -fpack-struct -fshort-enums -std=3Dgnu99 -funsigned-char -funsigned-bitfields -save-temps -Wall -Wextra -fno-strict-aliasing -fwrapv -mmcu=3Datmega16 -DF_CPU=3D1000000UL test.c It should have a "lpm" instruction somewhere in the asm output. The res= ult is "orig" not being copied to "dest". The compiler generates correct code when the PROGMEM macro is removed b= ut it generates a copy of the constant in the SRAM which is undesirable because I=C2=B4m 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=3Dc,c++ --prefix=3D/usr/lib --infodir=3D/usr/share/info --mandir=3D/usr/share/man --bindir=3D/usr/bin --libexecdir=3D/usr/lib --libdir=3D/usr/lib --enable-sh= ared --with-system-zlib --enable-long-long --enable-nls --without-included-gette= xt --disable-checking --disable-libssp --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Davr