Test fails to build in C++20 (Issue #22599)

195 views
Skip to first unread message

PB

unread,
Jul 4, 2022, 4:24:26 AM7/4/22
to wx-...@googlegroups.com, Subscribed

Building tests (via CMake) in C++20 mode fails both with GCC (v12.1) and MSVC (v17.2.5) in Catch code.

Error message from MSVC:

Error C2280 'std::basic_ostream<char,std::char_traits> &std::operator <<<std::char_traits>(std::basic_ostream<char,std::char_traits> &,const wchar_t *)': attempting to reference a deleted function (compiling source file D:\Dev\Desktop!Lib\wxWidgets-PB\tests\misc\dynamiclib.cpp) test_base D:\Dev\Desktop!Lib\wxWidgets-PB\3rdparty\catch\include\internal\catch_result_builder.h 50
Error C2088 '<<': illegal for class (compiling source file D:\Dev\Desktop!Lib\wxWidgets-PB\tests\misc\dynamiclib.cpp) test_base D:\Dev\Desktop!Lib\wxWidgets-PB\3rdparty\catch\include\internal\catch_result_builder.h 50

This is the offending line
catch-resbuilder


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22599@github.com>

VZ

unread,
Jul 4, 2022, 6:41:12 AM7/4/22
to wx-...@googlegroups.com, Subscribed

I'll try to look at this. Which source file is being compiled when this error happens?


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22599/1173660574@github.com>

PB

unread,
Jul 4, 2022, 7:23:43 AM7/4/22
to wx-...@googlegroups.com, Subscribed

Which source file is being compiled when this error happens?

It is here:
https://github.com/wxWidgets/wxWidgets/blob/6c65510a2c2123bd94ba0414db106327e04e40f6/tests/misc/dynamiclib.cpp#L102
with error message

3>dynamiclib.cpp
3>D:\Dev\Desktop\!Lib\wxWidgets-PB\3rdparty\catch\include\internal\catch_result_builder.h(50,26): 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
3>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\ostream(961): message : see declaration of 'std::operator <<'
3>D:\Dev\Desktop\!Lib\wxWidgets-PB\tests\misc\dynamiclib.cpp(102): message : see reference to function template instantiation 'Catch::ResultBuilder &Catch::ResultBuilder::operator <<<const wxChar*>(const T &)' being compiled
3>        with
3>        [
3>            T=const wxChar *
3>        ]
3>D:\Dev\Desktop\!Lib\wxWidgets-PB\3rdparty\catch\include\internal\catch_result_builder.h(50,26): error C2088: '<<': illegal for class

The obvious quick fix would be

diff --git a/tests/misc/dynamiclib.cpp b/tests/misc/dynamiclib.cpp
index 8747c702fb..aff81deffa 100644
--- a/tests/misc/dynamiclib.cpp
+++ b/tests/misc/dynamiclib.cpp
@@ -87,7 +87,7 @@ TEST_CASE("DynamicLibrary::Load", "[dynlib]")
 #ifdef __WINDOWS__
     SECTION("A/W")
     {
-        static const wxChar *FUNC_NAME_AW = wxT("lstrlen");
+        static const char *FUNC_NAME_AW = "lstrlen";
 
         typedef int (wxSTDCALL *wxStrlenTypeAorW)(const wxChar *);
         wxStrlenTypeAorW

But I suppose FUNC_NAME_AW uses wxChar for a reason even if I cannot see it, so it cannot be that simple...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22599/1173701735@github.com>

VZ

unread,
Jul 4, 2022, 7:37:45 PM7/4/22
to wx-...@googlegroups.com, Subscribed

Closed #22599 as completed via 8d3812a.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/22599/issue_event/6930493926@github.com>

VZ

unread,
Jul 4, 2022, 7:38:31 PM7/4/22
to wx-...@googlegroups.com, Subscribed

I think it can indeed be that simple, thanks, and the only reason for using wxT() here was due to this code originating in pre-3.0 days when it was needed to compile in Unicode mode. So I've just committed your fix with a tiny change, thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22599/1174460521@github.com>

Reply all
Reply to author
Forward
0 new messages