-
Notifications
You must be signed in to change notification settings - Fork 785
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
Inline functions in a referenced project optimized incorrectly #17903
Comments
What's the exception? What's yielded in the nightly 9.0 sdk? Does it change with realsig off? It could also be related to the additional equality generated. |
To be clear the last equality check reads |
I see, thanks. It appears that it's failing in SDK 6.0, could've been there forever. |
That's some awkward codegen. We will need to see whether it's a recent regression. If it is, we need to fix it for 9.0.200 |
In the attached example, we create three types;
In each of these we override equality and comparison operators, using inline functions to improve performance for ID3. (Note that this repro is a minimal example from more complicated code where this makes more sense!)
We create instances of each in the console app. and check that two unequal values of each type are reported as unequal by the compiler.
In Release mode only, the third assertion, that two obviously different instances of ID3 are unequal fails.
To repro, please run the attached program.
repro.zip
Expected behavior
I expect the program to exit with code 0.
Actual behavior
An exception is thrown in the last equality check, for
aBarBar
versusbBarBar
Known workarounds
Running this in debug mode fixes the issue.
Putting the definitions of ID and ID2 in the same project as ID3 fixes the issue. Because of this, I suspect this issue is something to do with incorrect optimisations around inlining functions from other projects.
Changing ID from a struct into a class by removing all the attributes associated with it fixes the issue.
Related information
Tested in .NET 8, SDKs 8.0.100 and 8.0.403
Windows 10.
VS 2022 for editing.
The text was updated successfully, but these errors were encountered: