From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9207 invoked by alias); 8 Mar 2009 17:21:52 -0000 Received: (qmail 9198 invoked by uid 22791); 8 Mar 2009 17:21:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 08 Mar 2009 17:21:47 +0000 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id n28HLj8Q017932 for ; Sun, 8 Mar 2009 10:21:45 -0700 Received: from wf-out-1314.google.com (wfa28.prod.google.com [10.142.1.28]) by wpaz29.hot.corp.google.com with ESMTP id n28HLh88008038 for ; Sun, 8 Mar 2009 10:21:43 -0700 Received: by wf-out-1314.google.com with SMTP id 28so1519408wfa.4 for ; Sun, 08 Mar 2009 10:21:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.11.20 with SMTP id 20mr2122434wfk.197.1236532902931; Sun, 08 Mar 2009 10:21:42 -0700 (PDT) In-Reply-To: References: Date: Sun, 08 Mar 2009 17:21:00 -0000 Message-ID: <8ac60eac0903081021j6eef006ckcb2458d27ed60c02@mail.gmail.com> Subject: Re: why so From: Paul Pluzhnikov To: Uladzislau Rezki Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00061.txt.bz2 On Sun, Mar 8, 2009 at 6:12 AM, Uladzislau Rezki wrote: > I am stuck with debugging C++ application that uses STL. > So, i have a simple code: > > #include > > 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": > > =A0 =A0(gdb) print s.c_str() > =A0 =A0$2 =3D 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, --=20 Paul Pluzhnikov