This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25789] New: A struct with one int and one char is treated as if it had two ints.
- From: "MWP2 at gmx dot at" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jan 2006 03:56:31 -0000
- Subject: [Bug c/25789] New: A struct with one int and one char is treated as if it had two ints.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I've tested it with gcc 3.4.4, 3.4.5, 4.0.2
#include<stdio.h>
struct S{
char c;
int i;
};
void main()
{
printf("%u\n",sizeof(struct S));
}
this prints out "8" instead of "5", if I change the int to short it's "4", if I
replace char by short its the same.
If I add char s to the struct it stays the same until it's more than 4 chars,
then the size increases by 4(with int)
if this is a feature it should it really should be switched off when invoking
gcc with -Os or -O0.
--
Summary: A struct with one int and one char is treated as if it
had two ints.
Product: gcc
Version: 3.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: MWP2 at gmx dot at
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25789