diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2019-05-22 10:56:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 10:56:54 -0700 |
commit | ce5a35f001b08470518ed85f78db7f360f9f77b8 (patch) | |
tree | 07e2a30b53954a4b90a3caeb2f1cedcc01b5e99e /tests/src/JIT/Regression/JitBlue | |
parent | 3a4ba5849ecc04a7a6749b6fb5328fa43b554deb (diff) | |
download | coreclr-ce5a35f001b08470518ed85f78db7f360f9f77b8.tar.gz coreclr-ce5a35f001b08470518ed85f78db7f360f9f77b8.tar.bz2 coreclr-ce5a35f001b08470518ed85f78db7f360f9f77b8.zip |
Test case for #24657 (#24721)
This bug is a duplicate of #18522. Adding the additional repro.
Close #24657
Diffstat (limited to 'tests/src/JIT/Regression/JitBlue')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs | 54 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj | 17 |
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs new file mode 100644 index 0000000000..be0f46b226 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; + +public class GitHub_24657 +{ + struct Wrapper<T> + { + public T Val { get; set; } + + public static implicit operator Wrapper<T>(T val) => new Wrapper<T> { Val = val }; + } + + struct TestStruct + { + public Wrapper<int> Field1; + public Wrapper<short> Field2; + public Wrapper<short> Field3; + + [MethodImpl(MethodImplOptions.NoInlining)] + public TestStruct(int field1) + { + this.Field1 = field1; + this.Field2 = 0; + this.Field3 = 0; + } + } + + public static int Main(string[] args) + { + int returnVal = 100; + var array = new [] { new TestStruct(123), new TestStruct(456) }; + if (array[1].Field1.Val != 456) + { + Console.WriteLine("Failed to set value correctly."); + returnVal = -1; + } + + array[0].Field3 = 100; + + if (array[1].Field1.Val != 456) + { + Console.WriteLine("Value is corrupted."); + returnVal = -1; + } + + System.Console.WriteLine(returnVal == 100 ? "Pass" : "Fail"); + return returnVal; + } +} + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj new file mode 100644 index 0000000000..c24f74b865 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24657/GitHub_24657.csproj @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <OutputType>Exe</OutputType> + <DebugType></DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> |