[Bug c/25789] New: A struct with one int and one char is treated as if it had two ints.

MWP2 at gmx dot at gcc-bugzilla@gcc.gnu.org
Sat Jan 14 03:56:00 GMT 2006


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



More information about the Gcc-bugs mailing list