Box-unbox optimization swallows InvalidCastException on different signs #71632
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
Values with different signs are casted with no exception while roundtripping through object.
Reproduction Steps
Expected behavior
Both methods throw InvalidCastException.
Actual behavior
Problem2 doesn't throw it.
Regression?
Yes, introduced probably in Box-unbox enum optimization introduced in #70167.
Known Workarounds
No response
Configuration
.Net 7 builds off main branch, Preview 5 doesn't reproduce it.
Other information
It's probably caused by
getTypeForPrimitiveValueClass
treating types of the same size as the same here:https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/jitinterface.cpp#L3974
The text was updated successfully, but these errors were encountered: