From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6484 invoked by alias); 29 Aug 2007 16:30:37 -0000 Received: (qmail 6475 invoked by uid 22791); 29 Aug 2007 16:30:37 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Aug 2007 16:30:25 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id D267D98153; Wed, 29 Aug 2007 16:30:24 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 686D398101; Wed, 29 Aug 2007 16:30:24 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1IQQQv-0008Tr-2T; Wed, 29 Aug 2007 12:30:21 -0400 Date: Wed, 29 Aug 2007 16:30:00 -0000 From: Daniel Jacobowitz To: Joel Brobecker Cc: Carlos Eduardo Seo , Luis Machado , gdb-patches@sourceware.org Subject: Re: [patch] ptype: show members of an unnamed struct inside an union Message-ID: <20070829163021.GA32337@caradoc.them.org> Mail-Followup-To: Joel Brobecker , Carlos Eduardo Seo , Luis Machado , gdb-patches@sourceware.org References: <46C4D20E.1010703@linux.vnet.ibm.com> <20070828171422.GB3874@adacore.com> <46D47155.5000403@linux.vnet.ibm.com> <20070828200356.GA3795@adacore.com> <46D4818C.1030001@linux.vnet.ibm.com> <20070828203420.GB3795@adacore.com> <20070829025618.GA26311@caradoc.them.org> <20070829043633.GD3795@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070829043633.GD3795@adacore.com> User-Agent: Mutt/1.5.15 (2007-04-09) 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: 2007-08/txt/msg00512.txt.bz2 On Tue, Aug 28, 2007 at 09:36:33PM -0700, Joel Brobecker wrote: > > > Does this case actually make any sense? I don't think you can access > > > this union in your C program either, or can you? > > > > GCC supports anonymous unions. There's a test for it in the GDB > > testsuite, too. > > But how can you access this union if the field doesn't have a name? > More precisely, using the example that Carlos sent: > > struct my_page { > union { > struct { int mapping; }; > }; > }; > > How do you access the union? In C, it would be "my_page_var.mapping". The union is transparent. I think GDB has some failures for anon-union.exp with recent GCC related to this... More interesting example. First you have: struct s { int x; int y; }; Later you switch to: struct s { int x; union { int y; void *z; }; }; The anonymous union lets s.y keep working. -- Daniel Jacobowitz CodeSourcery