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

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

Closed
panxn opened this issue Nov 14, 2023 · 7 comments
Closed

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

panxn opened this issue Nov 14, 2023 · 7 comments

Comments

@panxn
Copy link

panxn commented Nov 14, 2023

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 14, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 14, 2023
@ghost
Copy link

ghost commented Nov 14, 2023

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: panxn
Assignees: -
Labels:

area-System.Numerics, untriaged, needs-area-label

Milestone: -

@jkotas jkotas removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 14, 2023
@tannergooding
Copy link
Member

Could you clarify what version of the C++/CLI build tools you have installed?

I am not able to repro this using the following in VS 17.9 Preview 1:

  1. Open VS
  2. Create New project
  3. CLR Class Library (.NET)
  4. Add void test(System::IntPtr) {} to ClassLibrary1::Class1 in ClassLibrary1.h

This was also validated to be resolved in the last preview of VS 17.8. I am currently installing VS 17.8 RTM to see if something broke between the last preview and actual release.

@panxn
Copy link
Author

panxn commented Nov 14, 2023

@tannergooding Thanks for your reply! I just found it can build with VC toolset 14.38.
I have 14.36, 14.37 and 14.38 installed. 14.36 is the default one. The code can only compile with 14.38.

But the code can compile with 14.36 in previous net8 preview versions. What is changed? Could I go back to the old compiler behavior? I ask this question because it's almost impossible for us to use 17.8 immediately because time is very limited.

@tannergooding
Copy link
Member

Visual Studio 2022 17.8 is the minimum version required to work with .NET 8

C++/CLI had to update to support a particular feature of static virtuals in interfaces that they did not previously support as we needed to take advantage of it in .NET 8.

This lack of support in C++/CLI was found back around .NET 8 Preview 4-5, at which point we temporarily removed the neded API. This was added back for RTM once the C++/CLI fix landed (which was only in the last preview of VS 2022 17.8).

@panxn
Copy link
Author

panxn commented Nov 14, 2023

Is there any workaround that I can use? Is it possible for me to "temporarily removed the needed API" like you did? We have no enough time.

@tannergooding
Copy link
Member

There is not.

If you are targeting .NET 8 and using C++/CLI, then you need C++/CLI 14.38. This necessitates using VS 2022 17.8.

@panxn
Copy link
Author

panxn commented Nov 14, 2023

I see. Thanks for your help!

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

3 participants