why so
Paul Pluzhnikov
ppluzhnikov@google.com
Sun Mar 8 17:21:00 GMT 2009
On Sun, Mar 8, 2009 at 6:12 AM, Uladzislau Rezki <urezki@gmail.com> wrote:
> I am stuck with debugging C++ application that uses STL.
> So, i have a simple code:
>
> #include <iostream>
>
> static int
> test(std::string s)
Note that passing strings by value is very inefficient.
You should probably pass 'const string &' instead, and this will
also cure the glitch you are observing.
> while debugging *test* function, i try to print s variable and
> i see following stauff, thought i expect to see "hello":
>
> (gdb) print s.c_str()
> $2 = 0xbf9486d8 "\024pR\b"
I can reproduce this using gcc-4.3.1, but not 4.2.2 or 4.4.4.
It's a GCC bug: it emits incorrect information for functions that
pass structs by value. I can't find it in GCC bugzilla though.
Cheers,
--
Paul Pluzhnikov
More information about the Gdb
mailing list