Bug 13427 - Incorrect address of std::string argument in constructor when passing by value
Summary: Incorrect address of std::string argument in constructor when passing by value
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 03:51 UTC by Dave
Modified: 2020-04-05 12:28 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Test case (967 bytes, text/plain)
2011-11-22 03:51 UTC, Dave
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave 2011-11-22 03:51:46 UTC
Created attachment 6070 [details]
Test case

When setting a breakpoint at a constructor, I cannot "print" an argument because gdb doesn't get its address correct. See attached.

It may be useful to note that it works properly at a class method (as opposed to the constructor).

gcc (Debian 4.5.3-1) 4.5.3
GNU gdb (GDB) 7.3-debian
Comment 1 Phil Armstrong 2015-03-24 17:30:43 UTC
This bug still affects gdb 7.9 - See this stack overflow thread: http://stackoverflow.com/questions/8980566/gdb-reports-wrong-address-for-parameter-in-c-objects-constructor#comment46681158_8980566
Comment 2 Phil Armstrong 2015-03-25 10:01:16 UTC
Addendum: clang++ -gdwarf-4 creates a binary that gdb debugs correctly, so maybe this is a gcc bug?
Comment 3 Hannes Domani 2020-04-05 12:28:19 UTC
(In reply to Phil Armstrong from comment #2)
> Addendum: clang++ -gdwarf-4 creates a binary that gdb debugs correctly, so
> maybe this is a gcc bug?

I can reproduce this problem when compiling with gcc up to version 8, but it works fine for me with gcc 9, so I guess you were right that this was a gcc bug (but I don't know which one).