Skip to content

enum / tag alignment is always 1 right now #1645

Closed
@nikomatsakis

Description

@nikomatsakis

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 with enum 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 replace ty::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.

Metadata

Metadata

Assignees

Labels

A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions