You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conclusion: members using native integer types are available in -langversion:8, and native integer types are visible through var, but use of new built-in operators and conversions are errors, other than identity conversions between native integer types and underlying types.
Should IntPtr arithmetic use nint operators?
Identity conversions between native integers and underlying types allow built-in operators for native integers to apply to underlying types.
Conclusion: built-in operators for native integer types, and conversions from native integer types, are ignored if none of the operands are native integers.
Are built-in conversions and operators available from -langversion:8?
// -langversion:8_= Lib.NativeInt +1;// nint.op_Addition(nint, nint) or IntPtr.op_Addition(IntPtr, int)?_= Lib.NativeInt *2;// nint.op_Multiply(nint, nint) or error?
Conclusion: use of built-in conversions and operators are errors in -langversion:8
Allow constant folding at runtime rather than compile time
Should unchecked constant expressions be calculated at runtime if platform-dependent? See u2 below.
constnintm=int.MaxValue;constnintu1=unchecked(m+1);// error CS0133: expression must be constantnintu2=unchecked(m+1);// calculated at runtime?
Should checked constant expressions be calculated at runtime if platform-dependent, perhaps with a warning that the value may overflow? See c2 below.
constnintm=int.MaxValue;constnintc1=checked(m+1);// error CS0220: overflows at compile time in checked modenintc2=checked(m+1);// calculated at runtime, warn at compile time?
Conclusion: constant folding is executed at runtime rather than compile-time if the result depends on the size of native integers, and in a checked context, a warning is reported that the result may overflow.
Which interfaces are implemented by nint and nuint?
Should nint and nuint implement all of the interfaces implemented by System.IntPtr and System.UIntPtr or an explicit set?
Conclusion: native integer types should implement all interfaces implemented by the underlying types, with corresponding substitution of underlying type arguments.
The text was updated successfully, but these errors were encountered:
Open LDM issues with native integers
Open issues for native integer support in C# 9.
Do native integer types leak into programs compiled with -langversion:8?
Conclusion: members using native integer types are available in -langversion:8, and native integer types are visible through
var
, but use of new built-in operators and conversions are errors, other than identity conversions between native integer types and underlying types.Should
IntPtr
arithmetic usenint
operators?Identity conversions between native integers and underlying types allow built-in operators for native integers to apply to underlying types.
Conclusion: built-in operators for native integer types, and conversions from native integer types, are ignored if none of the operands are native integers.
Are built-in conversions and operators available from -langversion:8?
Conclusion: use of built-in conversions and operators are errors in -langversion:8
Allow constant folding at runtime rather than compile time
Should
unchecked
constant expressions be calculated at runtime if platform-dependent? Seeu2
below.Should
checked
constant expressions be calculated at runtime if platform-dependent, perhaps with a warning that the value may overflow? Seec2
below.Conclusion: constant folding is executed at runtime rather than compile-time if the result depends on the size of native integers, and in a
checked
context, a warning is reported that the result may overflow.Which interfaces are implemented by
nint
andnuint
?Should
nint
andnuint
implement all of the interfaces implemented bySystem.IntPtr
andSystem.UIntPtr
or an explicit set?Conclusion: native integer types should implement all interfaces implemented by the underlying types, with corresponding substitution of underlying type arguments.
The text was updated successfully, but these errors were encountered: