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

[MSVC] CoreCLR failed to build due to error C2280 and C2088 with option /std:c++20 #85864

Closed
Zhaojun-Liu opened this issue May 6, 2023 · 2 comments · Fixed by #85995
Closed
Milestone

Comments

@Zhaojun-Liu
Copy link

Description

CoreCLR failed to build with MSVC due to error C2280 and error C2088 with option /std:c++20, detailed error message as follows:

F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2088: '<<': illegal for class

Reproduction Steps

  1. git clone https://github.com/dotnet/runtime F:\gitP\dotnet\runtime
  2. git -C "F:\gitP\dotnet\runtime" reset --hard b90c9cf
  3. set CL=/std:c++latest /permissive /wd5054 /wd5055 /wd5033 /D_HAS_STD_BYTE=0 /Zc:equalityRewrite-
  4. cd F:\gitP\dotnet\runtime
  5. .\build.cmd -subset clr+libs -c release -arch x64

Expected behavior

Build successfully.

Actual behavior

F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\hostpolicy_exports.cpp(11): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\hostpolicy_exports.cpp(11): error C2088: '<<': illegal for class
F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2088: '<<': illegal for class

Regression?

No response

Known Workarounds

add option /D_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20,the error will disappear.

Configuration

OS: Windows Server 2022
VS: VS2022 17.5.4
.NET 8.0

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 6, 2023
@ghost
Copy link

ghost commented May 6, 2023

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

CoreCLR failed to build with MSVC due to error C2280 and error C2088 with option /std:c++20, detailed error message as follows:

F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2088: '<<': illegal for class

Reproduction Steps

  1. git clone https://github.com/dotnet/runtime F:\gitP\dotnet\runtime
  2. git -C "F:\gitP\dotnet\runtime" reset --hard b90c9cf
  3. set CL=/std:c++latest /permissive /wd5054 /wd5055 /wd5033 /D_HAS_STD_BYTE=0 /Zc:equalityRewrite-
  4. cd F:\gitP\dotnet\runtime
  5. .\build.cmd -subset clr+libs -c release -arch x64

Expected behavior

Build successfully.

Actual behavior

F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\hostpolicy_exports.cpp(11): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\hostpolicy_exports.cpp(11): error C2088: '<<': illegal for class
F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2280: 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const wchar_t *)': attempting to reference a deleted function
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.35.32215\include\ostream(971): note: see declaration of 'std::operator <<'
  F:\gitP\dotnet\runtime\src\native\corehost\test\nativehost\comhost_test.cpp(64): error C2088: '<<': illegal for class

Regression?

No response

Known Workarounds

add option /D_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20,the error will disappear.

Configuration

OS: Windows Server 2022
VS: VS2022 17.5.4
.NET 8.0

Other information

No response

Author: Zhaojun-Liu
Assignees: -
Labels:

area-Host

Milestone: -

@elinor-fung elinor-fung removed the untriaged New issue has not been triaged by the area owner label May 8, 2023
@elinor-fung elinor-fung added this to the 8.0.0 milestone May 8, 2023
@elinor-fung
Copy link
Member

Looks like the test code is actually using mismatched types in those lines - it would have printed garbage to the output if it hit those error cases. I think those stream overloads were deleted in newer versions precisely to make it harder to accidentally do this.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label May 9, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label May 10, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants