Closed
Description
Right now, we do not compute the correct alignment for enum types. Effectively we treat them as [u8]
at all times. This causes a variety of problems. Mostly it causes poor interaction with shape code and C code, which assumes that we do alignment correctly. I think there is probably an issue for this but I haven't found one that specifically describes it.
Some symptoms:
-
1535: Replacing a type like
int
withenum foo { foo(int) }
is not equivalent. It will cause shape code to misbehave when doing comparisons and the like because shape code will try to align to a word boundary, but the data will be stored with no alignment at all. (For example, I tried to replacety::t
with such a type) - Converting tag discriminants from int to i32 does not work because the payloads are no longer properly aligned on 64-bit targets. Basically, it works now by accident because int is 64-bits and we don't have any payloads of greater than 8-byte alignment.