From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11393 invoked by alias); 14 Mar 2007 18:15:01 -0000 Received: (qmail 11347 invoked by uid 48); 14 Mar 2007 18:14:52 -0000 Date: Wed, 14 Mar 2007 18:15:00 -0000 Message-ID: <20070314181452.11346.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/31176] reorder class data members to minimize space waste In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "fang at csl dot cornell dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg01309.txt.bz2 ------- Comment #1 from fang at csl dot cornell dot edu 2007-03-14 18:14 ------- Interesting. Do the attributes apply to derived classes automatically? struct B __attribute__((reorder)) { char a; int b; }; struct D : public B { char c, d, e; }; Is D also allowed to reorder members a and b? even with an explicit __attribute__((reorder))? Would this break static_cast-ing from D to B due to change in layout? D d; int x = static_cast(d).b; // how does this work if D's layout is not a mere extension? This might warrant a diagnostic saying this might not do what is expected. (What DOES one expect?) Fang -- fang at csl dot cornell dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fang at csl dot cornell dot | |edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31176