[ python-Bugs-1709506 ] struct.calcsize() incorrect

SourceForge.net noreply at sourceforge.net
Sun Apr 29 12:38:20 CEST 2007


Bugs item #1709506, was opened at 2007-04-29 09:21
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1709506&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: JoelBondurant (joelbondurant)
Assigned to: Nobody/Anonymous (nobody)
Summary: struct.calcsize() incorrect

Initial Comment:
The result of:

import struct
struct.calcsize('cd') #returns 16

appears to be incorrect.  The correct result should be 1 + 8 = 9.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2007-04-29 12:38

Message:
Logged In: YES 
user_id=21627
Originator: NO

No, the result is correct as it stands. If you define

struct Foo{
  char c;
  double d;
};

on your system, and then compute sizeof(struct Foo) using the C compiler,
it will tell you that the struct is 16 bytes in size. Read some text about
alignment and padding.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1709506&group_id=5470


More information about the Python-bugs-list mailing list