This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: struct.calcsize() incorrect
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: joelbondurant, loewis
Priority: normal Keywords:

Created on 2007-04-29 07:21 by joelbondurant, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg31916 - (view) Author: JoelBondurant (joelbondurant) Date: 2007-04-29 07:21
The result of:

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

appears to be incorrect.  The correct result should be 1 + 8 = 9.
msg31917 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-04-29 10:38
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.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 44912
2007-04-29 07:21:27joelbondurantcreate