This repository was archived by the owner on Apr 5, 2024. It is now read-only.
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
#[repr(C)] C-like enums and out of range values #41
Closed
Description
@sdroege asked me the following on IRC, and I .. wasn't sure of the answer:
nmatsakis: if i have a repr(C) enum with values A=1, B=2. and a C function with that enum as return type returns "3", is that leading us to undefined behaviour already? is it guaranteed that converting the enum to the corresponding integer type will give "3" and nothing bad happens, and the only possible bad thing that could happen is that if there is a exhaustive match (for the compiler) on the enum... that it's actually not exhaustive (because 3) and from there on things go wrong?
I wasn't sure what I thought the answer should be.
Metadata
Metadata
Assignees
Labels
No labels