From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14793 invoked by alias); 3 Apr 2002 23:55:52 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 14785 invoked from network); 3 Apr 2002 23:55:51 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 3 Apr 2002 23:55:51 -0000 Received: from redhat.com (notinuse.cygnus.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id PAA00631; Wed, 3 Apr 2002 15:55:47 -0800 (PST) Message-ID: <3CAB93DA.5F51C87F@redhat.com> Date: Wed, 03 Apr 2002 15:55:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Accept-Language: en MIME-Version: 1.0 To: Jim Blandy CC: Jim Ingham , gdb-patches@sources.redhat.com Subject: Re: Trivial fix in value_sub References: <76AD507E-436C-11D6-890B-000393540DDC@apple.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-04/txt/msg00082.txt.bz2 Jim Blandy wrote: > > (Thanks for making value_add and value_sub consistent!) > > If I use an incomplete type in my program --- say, by making a > definition like this: > > struct foo *x; > > where there is no definition for `struct foo' in scope --- does GDB > set TYPE_LENGTH (TYPE_TARGET_TYPE (p)) to zero, where `p' is the type > of x? > > See, that code in value_add (and now in value_sub) is supposed to > handle void *; as an extension, GCC allows arithmetic on void * > values, treating sizeof (void) as one. This makes sense for void * > values, since they're often used as pointers to raw memory. > > However, for things like incomplete struct types, treating the size as > one is completely bogus. That's surely not the behavior the user > would expect; they may not even realize that the type is incomplete. I agree -- I think taking the sizeof an incomplete type should result in an error, just as it would in c/c++. > If GDB really does set the length of an incomplete struct type to > zero, then that code should really read something like: > > if (sz == 0 && TYPE_CODE (TYPE_TARGET_TYPE (type1)) == TYPE_CODE_VOID) > sz = 1; > > Can you tell me more about the context in which you noticed this > problem? Heh -- I bet I know. ;-)