This repository was archived by the owner on Jun 5, 2019. It is now read-only.
This repository was archived by the owner on Jun 5, 2019. It is now read-only.
ConstantExpression.ConvertToType is incorrect #177
Open
Description
The following code will generate a compile-time error:
ulong source;
float dest;
source = 1;
dest = source;
if (dest == 1F)
return 0;
else
return 1;
The conversion from source to dest (ulong to double) reinterprets the source's raw bytes as a float, resulting in the value 1.4E-45. Upon investigation, this issue is endemic to ConstantExpression and the way it converts values.
ConvertToType needs to take an object, instead of raw bytes as ulong, and have similar behavior to Convert.ChangeType. This is a relatively high-risk change.