I am trying to build some C++ code in the GitHub CI. This works for GCC and Clang, but compilation with MSVC fails in very weird ways.
The very first error is found at:
template <bool constant, bool nothrow, typename R, typename... Args>
struct Function_Ref_Base {
public:
using Function = R(Args...) noexcept(nothrow);
using Storage = const_if_t<void, constant>;
using Invoker = R(Storage*, Args...) noexcept(nothrow); // <<< error here
... which is:
function_ref.hpp(36,51): error C2065: 'nothrow': undeclared identifier [D:\a\ulight\ulight\build\ulight.vcxproj]
(compiling source file '../src/main/cpp/cpp.cpp')
Complete nonsense. The full compilation command is:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\CL.exe
/c /ID:\a\ulight\ulight\include /nologo
/W4 /WX-
/diagnostics:column
/O2 /Ob2
/D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\""
/EHsc /MD /GS
/fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline
/std:c++latest
/Fo"ulight.dir\Release\\"
/Fd"D:\a\ulight\ulight\build\Release\ulight.pdb"
/external:W4 /Gd /TP /errorReport:queue
D:\a\ulight\ulight\src\main\cpp\chars.cpp
D:\a\ulight\ulight\src\main\cpp\cpp.cpp
D:\a\ulight\ulight\src\main\cpp\lua.cpp
D:\a\ulight\ulight\src\main\cpp\mmml.cpp
D:\a\ulight\ulight\src\main\cpp\parse_utils.cpp
D:\a\ulight\ulight\src\main\cpp\ulight.cpp
According to CMake's output, the compiler is:
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.43.34808.0
-- The CXX compiler identification is MSVC 19.43.34808.0
This seems more up-to-date than the latest version available on Compiler Explorer. Despite that, I cannot reproduce the issue there.
Why would I get these bogus errors? The full log is at
I am trying to build some C++ code in the GitHub CI. This works for GCC and Clang, but compilation with MSVC fails in very weird ways.
The very first error is found at:
template <bool constant, bool nothrow, typename R, typename... Args>
struct Function_Ref_Base {
public:
using Function = R(Args...) noexcept(nothrow);
using Storage = const_if_t<void, constant>;
using Invoker = R(Storage*, Args...) noexcept(nothrow); // <<< error here
... which is:
function_ref.hpp(36,51): error C2065: 'nothrow': undeclared identifier [D:\a\ulight\ulight\build\ulight.vcxproj]
(compiling source file '../src/main/cpp/cpp.cpp')
Complete nonsense. The full compilation command is:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\CL.exe
/c /ID:\a\ulight\ulight\include /nologo
/W4 /WX-
/diagnostics:column
/O2 /Ob2
/D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\""
/EHsc /MD /GS
/fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline
/std:c++latest
/Fo"ulight.dir\Release\\"
/Fd"D:\a\ulight\ulight\build\Release\ulight.pdb"
/external:W4 /Gd /TP /errorReport:queue
D:\a\ulight\ulight\src\main\cpp\chars.cpp
D:\a\ulight\ulight\src\main\cpp\cpp.cpp
D:\a\ulight\ulight\src\main\cpp\lua.cpp
D:\a\ulight\ulight\src\main\cpp\mmml.cpp
D:\a\ulight\ulight\src\main\cpp\parse_utils.cpp
D:\a\ulight\ulight\src\main\cpp\ulight.cpp
According to CMake's output, the compiler is:
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.43.34808.0
-- The CXX compiler identification is MSVC 19.43.34808.0
This seems more up-to-date than the latest version available on Compiler Explorer. Despite that, I cannot reproduce the issue there.
Why would I get these bogus errors? The full log is at https://github/Eisenwave/ulight/actions/runs/14104181487/job/39506850293
Share Improve this question edited Mar 27 at 16:03 Jan Schultke asked Mar 27 at 10:34 Jan SchultkeJan Schultke 40.7k8 gold badges99 silver badges177 bronze badges 3- 1 Compile fine here – Jarod42 Commented Mar 27 at 10:43
- @Jarod42 minimal repro is in the answer now. – Jan Schultke Commented Mar 27 at 16:03
- I can have msvc ICE by removing added pointer Demo – Jarod42 Commented Mar 27 at 16:54
1 Answer
Reset to default 3While there are quite a few issues in the build, the most nonsensical message turned out to be a compiler bug (see report), with the following insane minimal reproducible example (https://godbolt./z/oYrr9oehG):
template <bool nothrow>
struct S {
// error C2065: 'nothrow': undeclared identifier
using type = int(void*) noexcept(nothrow);
type* member;
};
void f() {
S<false> s;
auto p = s.member;
}
Note that S
in the example is Function_Ref_Base
in the original.
The remaining messages are related to C++23 features that are not supported by MSVC yet, so I consider this issue solved.