This is the mail archive of the gdb@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]

Re: why so


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


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