https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96953
Bug ID: 96953
Summary: junk at end of line: convert const char[] to
std::string
Product: gcc
Version: 8.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alex.wolf at gmail dot com
Target Milestone: ---
compiler sends bad optimized data to assembler when compiling.
g++-8 --version
g++-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
content of: test.cpp
#include <string>
const char a[] = "\n";
std::string f() {
return std::string(a);
}
g++-8 -std=c++11 -Og -dA -ggdb -c test.cpp
Workarounds:
- use different compiler flags
- declare 'a' as ptr: const char *a = "\n";