repr(C)
enums with a variant that overflows the native enum type should warn
#108069
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-FFI
Area: Foreign function interface (FFI)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider this:
Assume that the targets native enum size is 4 bytes. Obviously
0x1_FFFF_FFFF
will overflow. This is accepted by the compiler, without warning. Instead it will silently use a larger underlying type.I think this should be a future incompatibility warning with an eye to making it a hard error in a future edition. Being explicit with, say,
repr(u64)
is better than doing so silently (especially with it being incompatible with MSVC). However, any warning would be good if others disagree.The text was updated successfully, but these errors were encountered: