From 0548884eea1bbd371abe35193161d92d2984e2c2 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 15:02:58 -0700 Subject: [PATCH 01/10] Address feedback from numeric IntPtr feature review --- .../Compiler Breaking Changes - DotNet 7.md | 28 +++++ .../Test/Emit2/Emit/NumericIntPtrTests.cs | 108 ++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index 6ef16fbdca75a..7a0384877a8b6 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -1,5 +1,33 @@ # This document lists known breaking changes in Roslyn after .NET 6 all the way to .NET 7. +## Checked operators on System.IntPtr and System.UIntPtr + +***Introduced in .NET SDK 7.0.500, Visual Studio 2022 version 17.3.*** + +When the platform supports numeric `IntPtr` and `UIntPtr` types (as indicated by the presence of +`System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint` +and `nuint` apply to those underlying types. +This means that on such platforms, `IntPtr` and `UIntPtr` have built-in `checked` operators, which +can now throw when an overflow occurs. + +```csharp +IntPtr M(IntPtr x, IntPtr y) +{ + checked + { + return x + y; // may now throw + } +} +``` + +Possible workarounds are: + +1. Specify `unchecked` context +2. Downgrade to a platform/TFM without numeric `IntPtr`/`UIntPtr` types + +Also, implicit conversions between `IntPtr`/`UIntPtr` and other numeric types are treated as standard +conversions on such platforms. This can affect overload resolution in some cases. + ## Nameof operator in attribute on method or local function ***Introduced in .NET SDK 7.0.400, Visual Studio 2022 version 17.3.*** diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs index 8d775a22686eb..3de1d5b45d9f4 100644 --- a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE; +using Microsoft.CodeAnalysis.CSharp.Symbols.Retargeting; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.CSharp.UnitTests; @@ -10065,6 +10066,113 @@ public static void M9(nuint{{s2Nullable}} x) { } CompileAndVerify(comp, expectedOutput: expected); } + [Fact] + public void RetargetingFromNonNumericToNumericIntPtrCorlib() + { + string lib_cs = """ +public class Base +{ + public virtual nint M() => 0; +} +"""; + var libComp = CreateEmptyCompilation(lib_cs, references: new[] { MscorlibRef_v20 }, assemblyName: "lib"); + libComp.VerifyDiagnostics(); + + string source = """ +public class Derived : Base +{ + public override nint M() => 0; +} +"""; + var comp = CreateNumericIntPtrCompilation(source, references: new[] { libComp.ToMetadataReference(), MscorlibRefWithoutSharingCachedSymbols }); + comp.VerifyDiagnostics( + // warning CS1701: Assuming assembly reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'lib' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy + Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin).WithArguments("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "lib", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "mscorlib").WithLocation(1, 1), + // warning CS1701: Assuming assembly reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'lib' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy + Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin).WithArguments("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "lib", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "mscorlib").WithLocation(1, 1), + // warning CS1701: Assuming assembly reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'lib' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy + Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin).WithArguments("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "lib", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "mscorlib").WithLocation(1, 1), + // warning CS1701: Assuming assembly reference 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' used by 'lib' matches identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' of 'mscorlib', you may need to supply runtime policy + Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin).WithArguments("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "lib", "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "mscorlib").WithLocation(1, 1) + ); + + var baseM = (RetargetingMethodSymbol)comp.GlobalNamespace.GetMember("Base.M"); + var baseNint = (PENamedTypeSymbol)baseM.ReturnType; + + var derivedM = (MethodSymbol)comp.GlobalNamespace.GetMember("Derived.M"); + var derivedNint = (PENamedTypeSymbol)baseM.ReturnType; + + Assert.Equal("nint", derivedNint.ToTestDisplayString()); + Assert.Same(baseNint, derivedNint); + } + + [Fact] + public void RetargetingFromNumericIntPtrToNonNumericCorlib() + { + string lib_cs = """ +public class Base +{ + public virtual nint M() => 0; +} +"""; + var libComp = CreateNumericIntPtrCompilation(lib_cs, references: new[] { MscorlibRefWithoutSharingCachedSymbols }, assemblyName: "lib"); + libComp.VerifyDiagnostics(); + + string source = """ +public class Derived : Base +{ + public override nint M() => 0; +} +"""; + var comp = CreateEmptyCompilation(source, references: new[] { libComp.ToMetadataReference(), MscorlibRef_v46 }); + comp.VerifyDiagnostics(); + + var baseM = (RetargetingMethodSymbol)comp.GlobalNamespace.GetMember("Base.M"); + var baseNint = (PENamedTypeSymbol)baseM.ReturnType; + + var derivedM = (MethodSymbol)comp.GlobalNamespace.GetMember("Derived.M"); + var derivedNint = (PENamedTypeSymbol)baseM.ReturnType; + + Assert.Equal("System.IntPtr", derivedNint.ToTestDisplayString()); + Assert.Same(baseNint, derivedNint); + } + + [Fact] + public void UnsignedRightShift() + { + string source = """ +public class C +{ + nint M1(nint x, int count) => x >>> count; + nuint M2(nuint x, int count) => x >>> count; + nint M3(nint x, int count) => checked(x >>> count); + nuint M4(nuint x, int count) => checked(x >>> count); + + System.IntPtr M5(System.IntPtr x, int count) => x >>> count; + System.UIntPtr M6(System.UIntPtr x, int count) => x >>> count; +} +"""; + var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols }); + comp.VerifyDiagnostics(); + var verifier = CompileAndVerify(comp); + var expectedIL = @" +{ + // Code size 4 (0x4) + .maxstack 2 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: shr.un + IL_0003: ret +} +"; + verifier.VerifyIL("C.M1", expectedIL); + verifier.VerifyIL("C.M2", expectedIL); + verifier.VerifyIL("C.M3", expectedIL); + verifier.VerifyIL("C.M4", expectedIL); + verifier.VerifyIL("C.M5", expectedIL); + verifier.VerifyIL("C.M6", expectedIL); + } + [Fact] public void VariousMembersToDecodeOnRuntimeFeatureType() { From 711f8f8516385fedbfda0c4aed073a4ec5d73ac6 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 15:51:52 -0700 Subject: [PATCH 02/10] Correct SDK version --- docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index 7a0384877a8b6..561619380ce6a 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -2,7 +2,7 @@ ## Checked operators on System.IntPtr and System.UIntPtr -***Introduced in .NET SDK 7.0.500, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** When the platform supports numeric `IntPtr` and `UIntPtr` types (as indicated by the presence of `System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint` From dd7e0bbab4dcffd47ecc7d5a719f150f0a9d79e3 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 15:53:10 -0700 Subject: [PATCH 03/10] Fix another SDK version --- docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index 561619380ce6a..f7550e5bb3d86 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -30,7 +30,7 @@ conversions on such platforms. This can affect overload resolution in some cases ## Nameof operator in attribute on method or local function -***Introduced in .NET SDK 7.0.400, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** When the language version is C# 11 or later, a `nameof` operator in an attribute on a method brings the type parameters of that method in scope. The same applies for local functions. From f151b7aa7ff3430325ed305e47ec8ccc8008b7b8 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 16:01:15 -0700 Subject: [PATCH 04/10] Address feedback --- docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index f7550e5bb3d86..ebe56e3e31325 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -4,14 +4,14 @@ ***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** -When the platform supports numeric `IntPtr` and `UIntPtr` types (as indicated by the presence of +When the platform supports __numeric__ `IntPtr` and `UIntPtr` types (as indicated by the presence of `System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint` and `nuint` apply to those underlying types. This means that on such platforms, `IntPtr` and `UIntPtr` have built-in `checked` operators, which can now throw when an overflow occurs. ```csharp -IntPtr M(IntPtr x, IntPtr y) +IntPtr M(IntPtr x, int y) { checked { From b931ecce091c2cfff4c783aefc24cf687b09b2c6 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 16:03:35 -0700 Subject: [PATCH 05/10] Name specific SDK previews --- docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index ebe56e3e31325..f3e9361b5a6a7 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -2,7 +2,7 @@ ## Checked operators on System.IntPtr and System.UIntPtr -***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 7.0.100 preview 5, Visual Studio 2022 version 17.3.*** When the platform supports __numeric__ `IntPtr` and `UIntPtr` types (as indicated by the presence of `System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint` @@ -30,7 +30,7 @@ conversions on such platforms. This can affect overload resolution in some cases ## Nameof operator in attribute on method or local function -***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 7.0.100 preview 4, Visual Studio 2022 version 17.3.*** When the language version is C# 11 or later, a `nameof` operator in an attribute on a method brings the type parameters of that method in scope. The same applies for local functions. From 33373b3e4d63786403315662b6b5372b42d807ea Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 16:23:00 -0700 Subject: [PATCH 06/10] Fix SDK version for nameof(parameter) --- docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index f3e9361b5a6a7..b231ab2af31ea 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -30,7 +30,7 @@ conversions on such platforms. This can affect overload resolution in some cases ## Nameof operator in attribute on method or local function -***Introduced in .NET SDK 7.0.100 preview 4, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 6.0.400, Visual Studio 2022 version 17.3.*** When the language version is C# 11 or later, a `nameof` operator in an attribute on a method brings the type parameters of that method in scope. The same applies for local functions. From d2dede838462cdafa70e9a8d610653b992ae7264 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 16:28:51 -0700 Subject: [PATCH 07/10] Correct test --- .../CSharp/Compiler Breaking Changes - DotNet 7.md | 2 +- .../CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index b231ab2af31ea..a8ef3104df489 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -2,7 +2,7 @@ ## Checked operators on System.IntPtr and System.UIntPtr -***Introduced in .NET SDK 7.0.100 preview 5, Visual Studio 2022 version 17.3.*** +***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.*** When the platform supports __numeric__ `IntPtr` and `UIntPtr` types (as indicated by the presence of `System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint` diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs index 3de1d5b45d9f4..9fa313c83141c 100644 --- a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs @@ -10100,7 +10100,7 @@ public class Derived : Base var baseNint = (PENamedTypeSymbol)baseM.ReturnType; var derivedM = (MethodSymbol)comp.GlobalNamespace.GetMember("Derived.M"); - var derivedNint = (PENamedTypeSymbol)baseM.ReturnType; + var derivedNint = (PENamedTypeSymbol)derivedM.ReturnType; Assert.Equal("nint", derivedNint.ToTestDisplayString()); Assert.Same(baseNint, derivedNint); @@ -10131,10 +10131,11 @@ public class Derived : Base var baseNint = (PENamedTypeSymbol)baseM.ReturnType; var derivedM = (MethodSymbol)comp.GlobalNamespace.GetMember("Derived.M"); - var derivedNint = (PENamedTypeSymbol)baseM.ReturnType; + var derivedNint = (NativeIntegerTypeSymbol)derivedM.ReturnType; - Assert.Equal("System.IntPtr", derivedNint.ToTestDisplayString()); - Assert.Same(baseNint, derivedNint); + Assert.Equal("System.IntPtr", baseNint.ToTestDisplayString()); + Assert.Equal("nint", derivedNint.ToTestDisplayString()); + Assert.Same(baseNint, derivedNint.UnderlyingNamedType); } [Fact] From 420c7111f464c3438cc6bcab9c360ac0318171ea Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 16:45:17 -0700 Subject: [PATCH 08/10] Add test and doc for overflow in conversion --- .../Compiler Breaking Changes - DotNet 7.md | 5 ++++ .../Test/Emit2/Emit/NumericIntPtrTests.cs | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index a8ef3104df489..e1f2650911158 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -18,6 +18,11 @@ IntPtr M(IntPtr x, int y) return x + y; // may now throw } } + +IntPtr M2(ulong ul) +{ + return checked((IntPtr)ul); // may now throw +} ``` Possible workarounds are: diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs index 9fa313c83141c..c314a8bd7064a 100644 --- a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs @@ -10174,6 +10174,33 @@ .maxstack 2 verifier.VerifyIL("C.M6", expectedIL); } + [Fact] + public void OverflowPointerConversion() + { + string source = """ +using System; +ulong ul = ulong.MaxValue; + +try +{ + IntPtr i = checked((IntPtr)ul); +} +catch (System.OverflowException) +{ + Console.Write("RAN "); +} + +IntPtr j = unchecked((IntPtr)ul); +if (j == -1) +{ + Console.Write("RAN"); +} +"""; + var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols }); + comp.VerifyDiagnostics(); + CompileAndVerify(comp, expectedOutput: "RAN RAN"); + } + [Fact] public void VariousMembersToDecodeOnRuntimeFeatureType() { From dc78bb1ee8891401cef921106d66afac6281e525 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 17:03:50 -0700 Subject: [PATCH 09/10] Change to use void* conversion --- .../Compiler Breaking Changes - DotNet 7.md | 4 +- .../Test/Emit2/Emit/NumericIntPtrTests.cs | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md index e1f2650911158..e4a592fca6c1f 100644 --- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md +++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md @@ -19,9 +19,9 @@ IntPtr M(IntPtr x, int y) } } -IntPtr M2(ulong ul) +unsafe IntPtr M2(void* ptr) { - return checked((IntPtr)ul); // may now throw + return checked((IntPtr)ptr); // may now throw } ``` diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs index c314a8bd7064a..631e7c47ba388 100644 --- a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs @@ -10179,26 +10179,36 @@ public void OverflowPointerConversion() { string source = """ using System; -ulong ul = ulong.MaxValue; - -try -{ - IntPtr i = checked((IntPtr)ul); -} -catch (System.OverflowException) +class C { - Console.Write("RAN "); -} + public unsafe static void Main() + { + void* ptr = (void*)ulong.MaxValue; -IntPtr j = unchecked((IntPtr)ul); -if (j == -1) -{ - Console.Write("RAN"); + try + { + IntPtr i = checked((IntPtr)ptr); + } + catch (System.OverflowException) + { + Console.Write("OVERFLOW "); + } + + IntPtr j = unchecked((IntPtr)ptr); + if (j == (IntPtr)(-1)) + { + Console.Write("RAN"); + } + } } """; - var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols }); + var comp = CreateNumericIntPtrCompilation(source, references: new[] { MscorlibRefWithoutSharingCachedSymbols }, options: TestOptions.UnsafeReleaseExe); + comp.VerifyDiagnostics(); + CompileAndVerify(comp, expectedOutput: "OVERFLOW RAN", verify: Verification.Skipped); + + comp = CreateCompilation(source, options: TestOptions.UnsafeReleaseExe); comp.VerifyDiagnostics(); - CompileAndVerify(comp, expectedOutput: "RAN RAN"); + CompileAndVerify(comp, expectedOutput: "RAN", verify: Verification.Skipped); } [Fact] From 3b8fbc3198e774ac9f7cdd3059d322be0cd1f66a Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Thu, 19 May 2022 17:08:57 -0700 Subject: [PATCH 10/10] comment --- src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs index 631e7c47ba388..0d3a25ea598aa 100644 --- a/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs @@ -10177,6 +10177,7 @@ .maxstack 2 [Fact] public void OverflowPointerConversion() { + // Breaking change string source = """ using System; class C