From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25326 invoked by alias); 28 Sep 2002 23:52:23 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 25319 invoked from network); 28 Sep 2002 23:52:21 -0000 Received: from unknown (HELO bothner.com) (216.102.199.253) by sources.redhat.com with SMTP; 28 Sep 2002 23:52:21 -0000 Received: from bothner.com (eureka.bothner.com [192.168.1.9]) by bothner.com (8.11.6/8.11.6) with ESMTP id g8SNwJU32756; Sat, 28 Sep 2002 16:58:20 -0700 Message-ID: <3D964147.6020406@bothner.com> Date: Sat, 28 Sep 2002 16:55:00 -0000 From: Per Bothner User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020814 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Henderson CC: "gcc@gcc.gnu.org" Subject: Re: C ABI: struct/union inconsistency References: <20020928100655.A10847@hollebeek.com> <48190000.1033234561@warlock.codesourcery.com> <20020928192325.GA30150@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-09/txt/msg01176.txt.bz2 Richard Henderson wrote: > No, that's not what we want. > > > struct foo { > #ifdef SMP > long long count; > long lock; > #endif > }; > > Here, attribute((nopadding)) would leave foo with size 12, > instead of the required size 16 when SMP is defined. > > We _only_ want to change the zero-size-ness of this struct. Well, this can handled: #ifndef SMP __attribute__(nopadding)__ #endif That is not to say whether re-using nopadding for two (related) purposes would be a good idea or not, but we *could* do so. Another (wild) idea: Allow "negative" dizes - or fields that don't count to the final size: struct foo { int a; __size_cutoff_; int b; }; In this case, sizeof(struct foo)==sizeof(int). If you access a 'b', it will be actually be access from the *next* field. This would be like: struct foo { int a; int __b[0]; }; except b is not an array. Note: I don't say this is a terribly useful feature - but then some would say that empty structs aren't terribly useful either. Then an empty struct is: struct foo { __size_cutoff; :; -- --Per Bothner per@bothner.com http://www.bothner.com/per/