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

[NativeAOT] PlatformNotSupportedException when creating an array #74299

Closed
sa-exe opened this issue Aug 20, 2022 · 1 comment
Closed

[NativeAOT] PlatformNotSupportedException when creating an array #74299

sa-exe opened this issue Aug 20, 2022 · 1 comment

Comments

@sa-exe
Copy link

sa-exe commented Aug 20, 2022

The following code produces a PlatformNotSupportedException when compiled using the NativeAOT toolchain with all the default settings:

var a = new[] { 42, 42, 42 };
Console.WriteLine(a.Length);
Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
   at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowPlatformNotSupportedException() + 0x24
   at Program.<Main>$(String[]) + 0x9
   at dotnet7aot!<BaseAddress>+0x1b3f13

Whether it crashes or not somehow depends on the contents of the array. For instance, this code will run just fine:

var a = new[] { 0, 42, 42 };
Console.WriteLine(a.Length);

csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

</Project>

Platform: win-x64
SDK: 7.0.100-preview.7.22377.5
ILCompiler: 7.0.0-preview.7.22375.6

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 20, 2022
@teo-tsirpanis
Copy link
Contributor

Duplicate of dotnet/roslyn#62864.

@teo-tsirpanis teo-tsirpanis closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants