This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/70999] New: String incorrectly placed in flash instead of RAM when building with -ffunction-sections
- From: "gigo121 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 07 May 2016 15:07:58 +0000
- Subject: [Bug target/70999] New: String incorrectly placed in flash instead of RAM when building with -ffunction-sections
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70999
Bug ID: 70999
Summary: String incorrectly placed in flash instead of RAM when
building with -ffunction-sections
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gigo121 at gmail dot com
Target Milestone: ---
Created attachment 38436
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38436&action=edit
Test source code
When building with AVR-GCC 6.1.0, -ffunction-sections and any optimization
level other than -O0 then strings that are passed as a parameter to a function
like puts("whatever") will be stored in flash instead of RAM.
However, this will correctly store myString in RAM with -ffunction-sections:
static const char myString[] = "whatever";
puts(myString);
avr-gcc -mmcu=atmega328 -Wall -Wextra -O1 -ffunction-sections main.c