public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: gad@reymad.com To: gcc-gnats@gcc.gnu.org Subject: c/6385: sizeof fails calculating size of an structure (sizeof(struct my_struct)) Date: Sat, 20 Apr 2002 06:46:00 -0000 [thread overview] Message-ID: <20020420133630.3343.qmail@sources.redhat.com> (raw) >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 <stdio.h> 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:
next reply other threads:[~2002-04-20 13:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-20 6:46 gad [this message] 2002-04-20 7:01 neil
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020420133630.3343.qmail@sources.redhat.com \ --to=gad@reymad.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).