Bug 70999 - AVR: String incorrectly placed in flash instead of RAM when building with -ffunction-sections
Summary: AVR: String incorrectly placed in flash instead of RAM when building with -ff...
Status: RESOLVED DUPLICATE of bug 71151
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-07 15:07 UTC by gigo121
Modified: 2016-05-21 10:31 UTC (History)
1 user (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test source code (332 bytes, text/x-csrc)
2016-05-07 15:07 UTC, gigo121
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gigo121 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 ***