Skip to content
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

New nullable warnings when building runtime #46577

Closed
RikkiGibson opened this issue Aug 5, 2020 · 6 comments
Closed

New nullable warnings when building runtime #46577

RikkiGibson opened this issue Aug 5, 2020 · 6 comments
Assignees
Milestone

Comments

@RikkiGibson
Copy link
Contributor

RikkiGibson commented Aug 5, 2020

Version Used: 81c5d71

Steps to Reproduce:

Build the Roslyn packages and set up your dotnet/runtime enlistment similar to #46575. Then run .\Build.cmd in your dotnet/runtime enlistment. You might also be able to use a method like https://github.com/dotnet/runtime/pull/40197/files#diff-8b8f08ffbf7b863fb3700c1718eeb4cbR20 using a recent build like 3.8.0-2.20404.11 to simply reference the most recently build release packages.

Expected Behavior:
Builds without nullable warnings

Actual Behavior:
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(476,57): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(477,60): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(555,75): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs(1057,31): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs(45,32): error CS8601: Possible null reference assignment. [src\coreclr\src\System.Private.CoreLib\System.Private.CoreLib.csproj]

The warnings seem to involve generic substitution or taking a ref to an unconstrained type parameter. @cston do you have any idea what could be happening here?

@cston
Copy link
Member

cston commented Aug 18, 2020

The new warnings are for cases such as the following. The warning looks correct, although it was not reported with earlier builds.

#nullable enable

interface I { }

class Program
{
    static void F0<T>(ref T x, ref T y)
    {
    }
    static void F<T>(ref T x, ref T y) where T : I
    {
        if (x == null) { }
        F0(ref x, ref y); // warning: x may be null
    }
}

@cston cston removed the Bug label Aug 18, 2020
@RikkiGibson
Copy link
Contributor Author

Oh, interesting, so is it because one of the Ts is constrained to non-nullable interface?

Would it make sense to send a patch to the runtime with a suggested fix, or just find a code owner and give a heads up?

@cston
Copy link
Member

cston commented Aug 19, 2020

It looks like the new warnings are reported from #46405.

@cston
Copy link
Member

cston commented Aug 20, 2020

Resolved in dotnet/runtime#41046.

@cston cston closed this as completed Aug 20, 2020
@charsleysa
Copy link

charsleysa commented Sep 19, 2020

@cston it seems that EventCounter.cs was missed in the PR dotnet/runtime#41046 and still has the issue in the release/5.0 branch but in master has been fixed by an unrelated PR dotnet/runtime#42174

@cston
Copy link
Member

cston commented Sep 19, 2020

it seems that EventCounter.cs was missed in the PR dotnet/runtime#41046 and still has the issue in the release/5.0 branch but in master has been fixed

Thanks @charsleysa. It looks like the issue has been fixed in the release/5.0-rc2 branch in dotnet/runtime@4690f4e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants