From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12099 invoked by alias); 6 Dec 2005 13:08:09 -0000 Received: (qmail 12082 invoked by uid 48); 6 Dec 2005 13:08:07 -0000 Date: Tue, 06 Dec 2005 13:08:00 -0000 Message-ID: <20051206130807.12081.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/25274] sizeof(struct) fails for 'unlucky' structure In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2005-12/txt/msg00548.txt.bz2 List-Id: ------- Comment #1 from rguenth at gcc dot gnu dot org 2005-12-06 13:08 ------- The C standard allows for arbitrary padding in between elements, so this behavior is expected. Use __attribute__((packed)) on the type to get a struct without padding if you need that for whatever reason (it will be slower to access unaligned fields). You can also sort the fields starting with elements with the largest size to minimize required padding. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25274