Skip to content

c++/cli compile error 3611 if System::IntPtr is used #94723

Closed
@panxn

Description

@panxn

Description

I'm using the latest .NET8 and VS 17.8

It's a compile error for c++/cli:

1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): error C3611: 'System::Numerics::INumberBase::System::IUtf8SpanFormattable.TryFormat': a sealed function cannot have a pure-specifier
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::INumberBase' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::INumber' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::IBinaryNumber' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::Numerics::IBinaryInteger' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>C:\Users\admin\source\repos\Project1\Project1\Source.cpp(5,1): message : This diagnostic occurred while importing type 'System::IntPtr' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1

It happens as long as System::IntPtr is used. For example, add a function in c++/cli project:

void test(System::IntPtr) {}

These code can compile with .NET8 preview versions (preview, rc1, rc2), but fails with today's .NET8 official version 8.0.100

This problem is pretty urgent for us because our product is very close to the release date (we were waiting for .NET8 official release). Could you please take a look right now? Is there any workaround that we can use to make build pass?

I have encountered this problem in one .NET8 daily build months ago (#88840 (comment)), then it was gone. I don't understand why it comes back in today's official version.

Just FYI, I also reported a similar bug dotnet/winforms#9644, it's not urgent.

Reproduction Steps

create c++/cli project in VS.

add function:

void test(System::IntPtr) {}

build fails

Expected behavior

build should pass

Actual behavior

build fails

Regression?

Yes, it's good in .NET8 preview versions.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions