Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Uladzislau Rezki <urezki@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: why so
Date: Sun, 08 Mar 2009 17:21:00 -0000	[thread overview]
Message-ID: <8ac60eac0903081021j6eef006ckcb2458d27ed60c02@mail.gmail.com> (raw)
In-Reply-To: <e4957ae10903080612g58504140l77198502fa52ca57@mail.gmail.com>

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


  reply	other threads:[~2009-03-08 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-08 13:12 Uladzislau Rezki
2009-03-08 17:21 ` Paul Pluzhnikov [this message]
2009-03-09  9:24   ` Uladzislau Rezki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ac60eac0903081021j6eef006ckcb2458d27ed60c02@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb@sourceware.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox