This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB 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 c++/21480] New: Gdb can't pretty print strings from gcc 7.1/6.3 with -flto


https://sourceware.org/bugzilla/show_bug.cgi?id=21480

            Bug ID: 21480
           Summary: Gdb can't pretty print strings from gcc 7.1/6.3 with
                    -flto
           Product: gdb
           Version: 7.12.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: alexandre.nunes at gmail dot com
  Target Milestone: ---

Created attachment 10045
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10045&action=edit
testcase

With this example, compiled with g++ -ggdb3 -std=gnu++1z -Og and with/without
-flto:

#include <string>
#include <iostream>
static void print(const std::string &s)
{
    std::cout << s << "\n";
}
int main() {
    std::string s("test");
    print(s);
}

if we set a breakpoint in the print function, run and type "p s":

without lto:

Breakpoint 1, print (s="test") at test.cpp:4
4       {
(gdb) p s
$1 = "test"
(gdb) 


with -flto:

Breakpoint 1, print (s=...) at test.cpp:4
4       {
(gdb) p s
$1 = (const string &) @0x7fffffffdfd0: {_M_dataplus = {_M_p = 0x7fffffffdfe0
"test"}, _M_string_length = 4, {
    _M_local_buf = "test\000\177\000\000\000\000\000\000\000\000\000",
_M_allocated_capacity = 139639930447220}}
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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