From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5288 invoked by alias); 20 Apr 2002 13:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5268 invoked by uid 71); 20 Apr 2002 13:46:00 -0000 Resent-Date: 20 Apr 2002 13:46:00 -0000 Resent-Message-ID: <20020420134600.5267.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gad@reymad.com Received:(qmail 3344 invoked by uid 61); 20 Apr 2002 13:36:30 -0000 Message-Id:<20020420133630.3343.qmail@sources.redhat.com> Date: Sat, 20 Apr 2002 06:46:00 -0000 From: gad@reymad.com Reply-To: gad@reymad.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/6385: sizeof fails calculating size of an structure (sizeof(struct my_struct)) X-SW-Source: 2002-04/txt/msg01029.txt.bz2 List-Id: >Number: 6385 >Category: c >Synopsis: sizeof fails calculating size of an structure (sizeof(struct my_struct)) >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Sat Apr 20 06:46:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Gonzalo Aguilar : gad@reymad.com >Release: gcc-3.0.4 >Organization: >Environment: linux 2.4.17 glibc 2.2.3 >Description: This structure: struct msh_header { char charid[3]; int objs; }; is evaluated as a 8 bytes size object. It sould be 7 bytes. It seems that aligns data to a 4 byte boundary but this is not what should happen cause structure MUST be 7. Even this will be 8 bytes struct msh_header { char charid[1]; int objs; }; And this 12 bytes size: struct msh_header { char charid[5]; int objs; }; >How-To-Repeat: Just compile this code #include struct msh_header { char charid[3]; int objs; }; int main(int argc, char **argv) { printf("Size %i should be %i",sizeof(struct msh_header),7); return(1); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: