Skip to content

CS0220 on uint.MaxValue + (nuint)42 #51714

@lostmsu

Description

@lostmsu

Version Used: 3.10.0-1.21125.6 (93b8af2)

Steps to Reproduce: uint.MaxValue + (nuint)42

Expected Behavior:
uint + nuint => promote uint to nuint, then add.

Actual Behavior: error CS0220: The operation overflows at compile time in checked mode

Workaround:

uint uintMax = uint.MaxValue;
nuint size = uintMax + (nuint)42;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions