-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: "default(T) == null" does not emit a constant when T is Nullable<> #34906
Comments
why should it produce a constant? a variable of a Nullable type can be null (or not) |
e.g. |
Ah, oops. |
@benaadams @michkot anyway I can't repro it on my master, probably is already fixed (e.g. here? #32269) It's not the first time people use sharplab with .NET Core 3.0 to file issues against RyuJIT-master 😐 |
Thanks for looking into it. I will close the issue now then 👍 . Can you point me at some resources/docs so I can try it myself at current master @EgorBo ? (I had luck the last time with sharplab, so I tried it again). |
@michkot
once it finishes:
Also, let me promote my add-in for that: https://github.com/EgorBo/Disasmo (it still needs a pre-built runtime in Checked config) |
After toying with efficient detection of reference types / value types / nullable types I triggered a discovery of generic context issue #34641.
I now also find out that
default(T) == null
for T beingNullable<XXX>
in the following snippet does not produce a constant in ASM but rather builds what seems to be a composed "struct + HasValue bool" on stack and thencmp
s to0x0
.sharplab.io link with longer example
The produced assembly is (I guess) valid, although quite inefficient. (And I did not find other good way to determine whether type is reference of a non-nullable valuetype.)
The text was updated successfully, but these errors were encountered: