This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/25274] New: sizeof(struct) fails for 'unlucky' structure


the bug is in sizeof(element) - i've made unlucky structure, some
time ago, where sum of sizeof(each_element) gives size of 14 and
sizeof(whole_struct) returns 16. on old gcc-2.9.x there was the same
problem.
as an example program i've wrote shor one, that shows sizeof() from
struct having 14 char's table, 'unlucky' struct and sum of all elements sizes.

// sizeof(a)==16B instead of 14B...
struct a
{
 char           bfType[2];// 2B
 unsigned long  bfSize;// 4B
 unsigned short bfReserved1;// 2B
 unsigned short bfReserved2;// 2B
 unsigned long  bfOffBits;// 4B
};


// sizeof(b)==14B - OK!
struct b
{
 char nothing[14];
};


-- 
           Summary: sizeof(struct) fails for 'unlucky' structure
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: warg0d at go2 dot pl
 GCC build triplet: x86
  GCC host triplet: x86
GCC target triplet: x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25274


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]