landelare / ue5coro

A C++20 coroutine implementation for Unreal Engine 5 that feels almost native.
BSD 3-Clause Clear License
543 stars 48 forks source link

failed to compile "DoTests" in file DelegateAwaiterTest.cpp #13

Closed ameaninglessname closed 1 year ago

ameaninglessname commented 1 year ago
template<int N, typename... T>
void DoTests(FAutomationTestBase& Test)
{
    if constexpr (N < 8)
    {
        DoTest<(N & 4) != 0, (N & 2) != 0, (N & 1) != 0, T...>(Test);
        DoTests<N + 1, T...>(Test);
    }
}

image

Text utility(538): [C2338] static_assert failed: 'tuple index out of bounds' AsyncAwaiters.h(249): [C2338] see reference to class template instantiation 'std::tuple_element<18446744073709551615,std::tuple<>>' being compiled AsyncAwaiters.h(249): [C2338] see reference to alias template instantiation 'std::tuple_element_t<18446744073709551615,std::tuple<>>' being compiled AsyncAwaiters.h(257): [C2338] see reference to alias template instantiation 'UE5Coro::Private::TDecayedPayload<>::TType<18446744073709551615>' being compiled AsyncAwaiters.h(344): [C2338] see reference to class template instantiation 'UE5Coro::Private::TDecayedPayload<>' being compiled AsyncAwaiters.h(221): [C2338] see reference to function template instantiation 'UE5Coro::Private::TDynamicDelegateAwaiter::TDynamicDelegateAwaiter(T &)' being compiled AsyncAwaiters.h(221): [C2338] see reference to function template instantiation 'UE5Coro::Private::TDynamicDelegateAwaiter::TDynamicDelegateAwaiter(T &)' being compiled AsyncAwaiters.h(221): [C2338] while compiling class template member function 'UE5Coro::Private::TDynamicDelegateAwaiter UE5Coro::Private::TAwaitTransform::operator ()(T &)' AsyncCoroutine.h(259): [C2338] see reference to function template instantiation 'UE5Coro::Private::TDynamicDelegateAwaiter UE5Coro::Private::TAwaitTransform::operator ()(T &)' being compiled AsyncCoroutine.h(257): [C2338] see reference to class template instantiation 'UE5Coro::Private::TAwaitTransform' being compiled DelegateAwaiterTest.cpp(104): [C2338] see reference to function template instantiation 'UE5Coro::Private::TDynamicDelegateAwaiter UE5Coro::Private::FAsyncPromise::await_transform<`anonymous-namespace'::TSelect::FVoid&>(T)' being compiled DelegateAwaiterTest.cpp(277): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTest(FAutomationTestBase &)' being compiled DelegateAwaiterTest.cpp(277): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTests<4,>(FAutomationTestBase &)' being compiled DelegateAwaiterTest.cpp(277): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTests<3,>(FAutomationTestBase &)' being compiled DelegateAwaiterTest.cpp(277): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTests<2,>(FAutomationTestBase &)' being compiled DelegateAwaiterTest.cpp(277): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTests<1,>(FAutomationTestBase &)' being compiled DelegateAwaiterTest.cpp(333): [C2338] see reference to function template instantiation 'void `anonymous-namespace'::DoTests<0,>(FAutomationTestBase &)' being compiled utility(518): [C2794] 'type': is not a member of any direct or indirect base class of 'std::tuple_element<18446744073709551615,std::tuple<>>' AsyncAwaiters.h(249): [C2938] 'std::tuple_element_t' : Failed to specialize alias template
landelare commented 1 year ago

What's the compiler and its version?

ameaninglessname commented 1 year ago

What's the compiler and its version?

I run cl.exe from cmd.exe to get the version:

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64>cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32217.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.
landelare commented 1 year ago

What is UBT using? This line from the build output but with your numbers:

Using Visual Studio [...] toolchain (C:\Program Files\Microsoft Visual Studio\[...]) and Windows [...] SDK.

ameaninglessname commented 1 year ago

What is UBT using? This line from the build output but with your numbers:

Using Visual Studio [...] toolchain (C:\Program Files\Microsoft Visual Studio\[...]) and Windows [...] SDK.

7>Using Visual Studio 2022 14.35.32217 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).

landelare commented 1 year ago

Huh. Interesting. I only saw this bug on VS2019. I refreshed the v1.9-beta tag, does it work for you?

ameaninglessname commented 1 year ago

Huh. Interesting. I only saw this bug on VS2019. I refreshed the v1.9-beta tag, does it work for you?

Yes, worked! (Build succeeded) Any reason for this, just curious.

landelare commented 1 year ago

From what I could see, the compiler attempted to resolve a template that was in an if constexpr (something false) block instead of ignoring it completely.

landelare commented 1 year ago

Thanks for the bug report!