From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4579 invoked by alias); 24 Sep 2010 15:38:36 -0000 Received: (qmail 4569 invoked by uid 22791); 24 Sep 2010 15:38:35 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Sep 2010 15:38:30 +0000 Received: (qmail 14652 invoked from network); 24 Sep 2010 15:38:28 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Sep 2010 15:38:28 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch] const array types Date: Fri, 24 Sep 2010 16:40:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.33-29-realtime; KDE/4.4.2; x86_64; ; ) Cc: Joel Brobecker , Jan Kratochvil , Ken Werner References: <201009151920.37105.ken@linux.vnet.ibm.com> <20100923223709.GA25145@host1.dyn.jankratochvil.net> <20100924144234.GF3007@adacore.com> In-Reply-To: <20100924144234.GF3007@adacore.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201009241638.27072.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00437.txt.bz2 On Friday 24 September 2010 15:42:34, Joel Brobecker wrote: > > I have filed now http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45765 as > > I believe it could be fixed more at the DWARF producer side. > > For what it's worth, I tend to agree that this should be fixed > on the compiler side. I disagree: const struct { int x; } a; struct S { int x; }; const struct S b; It looks sane to me to not emit a whole new struct type based on struct S that includes a `const inst x' just for `b' (rather than DW_TAG_const_type pointing at struct S). Is `a' really any different? > > I would find this patch OK even if it fixes only the TYPE_CODE_ARRAY. > > I'm a little hesitant, still (but not objecting!). It it was a one-liner, > I'd be less reluctant, but I just want to make sure that the improvement > is worth the code we're adding. Yes, the output is more accurate, but > is it really all that bad to be missing the `const'? E.g., out of the blue, in C++ it can make the user call the wrong function from gdb, when there are overloads involved (, or templates, I guess): $ cat const.cc #include const struct { int x; } a = {0}; struct S { int x; }; const struct S b = {0}; __typeof__ (a.x) i1 = 0; __typeof__ (b.x) i2 = 0; void function (int *f) { printf ("called function (int *)\n"); } void function (const int *f) { printf ("called function (const int *)\n"); } int main () { function (&a.x); function (&b.x); function (&i1); function (&i2); } $ ./gdb ./const ... (gdb) start Temporary breakpoint 1 at 0x400638: file const.cc, line 27. ... Temporary breakpoint 1, main () at const.cc:27 27 function (&a.x); (gdb) call function(&a.x) called function (int *) ^^^^^^^^^^^^^^^^^^^^^^^ (gdb) n called function (const int *) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 function (&b.x); -- Pedro Alves