0

I have the following tagged union in my code: https://github.com/EarlGray/SECD/blob/f2e364f84d194aea5cef9257630bf931e9f88cab/secd.h#L217

When I compile it on 64 bit Linux or OS X using gcc or clang, size of cell_t is always 32 bytes (4 * sizeof(long), as expected).

When I compile it on Linux (Ubuntu 14.04, gcc 4.8) using -m32 switch, the size is 16 bytes (as expected).

When I compile the same code on OS X (10.9.5) using either gcc (4.8) or clang (Apple 6.0) with -m32, the size is 20 bytes. I tried to debug the program and to see if there are any union cases that might use the fifth word, haven't found any. It does not depend on levels of optimization and debug information presence.

Any ideas why sizeof(cell_t) is 20 bytes?

Dmytro Sirenko
  • 5,003
  • 21
  • 26

1 Answers1

2

On OS X:

sizeof(off_t) == 8

On Linux:

sizeof(off_t) == 4

You use that type in string_t. There may be other occasions of this, but that was the first that I came across.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173