Skip to content

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

@Zhaojun-Liu

Description

@Zhaojun-Liu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions