invalid enum value
not always detected where enum
size is not explicit
#11761
Labels
Milestone
Zig Version
0.9.1
Steps to Reproduce
@sentientwaffle and I found something interesting working on TigerBeetle's crash recovery:
In our case, we were accidentally accessing an enum on an untrusted data header, before checking the header's checksum. After casting some bytes into a message header, we were inadvertently checking
header.command == .prepare and header.valid_checksum()
(instead of the other way around).Expected Behavior
We expected Zig to catch this at runtime with
invalid enum value
for all invalid values.Actual Behavior
Unfortunately, some invalid values were bypassing the runtime check, and worse, colliding with valid values if they shared the same binary suffix.
The text was updated successfully, but these errors were encountered: