This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/70999] New: String incorrectly placed in flash instead of RAM when building with -ffunction-sections


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]