Bug 70999

Summary: AVR: String incorrectly placed in flash instead of RAM when building with -ffunction-sections
Product: gcc Reporter: ZK <zakkemble>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: gjl
Priority: P3    
Version: 6.1.0   
Target Milestone: ---   
Host: Target: avr
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: Test source code

Description ZK 2016-05-07 15:07:58 UTC
Created attachment 38436 [details]
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
Comment 1 Georg-Johann Lay 2016-05-21 10:31:21 UTC
Same as PR71151, more info there.

*** This bug has been marked as a duplicate of bug 71151 ***