-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Consider this F# program:
open System
[<Struct>]
type Image =
val data: voidptr
let LoadTextureFromMemory(): bool =
let image = Unchecked.defaultof<Image>
image.data = IntPtr.Zero.ToPointer()
let foo = LoadTextureFromMemory()Expected behavior
This program should work and put true into the foo variable.
Actual behavior
Unhandled exception. System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)
at Program.LoadTextureFromMemory()
at <StartupCode$ConsoleApp11>.$Program.main@() in T:\Temp\ConsoleApp11\ConsoleApp11\Program.fs:line 13
See the repro on sharplab as well.
Known workarounds
// open Microsoft.FSharp.NativeInterop
NativePtr.ofVoidPtr<byte> image.data = NativePtr.nullPtrRelated information
- Operating system: Windows 11
- .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET SDK 7.0.302
- Editing Tools (e.g. Visual Studio Version, Visual Studio): should not matter
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
Done