-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
Describe the bug
Following the changes from PR #1219, using the experimental/generator header in code built with /kernel (and hence no exception handling) now fails to compile with error C2980.
Command-line test case
C:\Users\kobyk\Documents\Stuff\ge>type ge.cpp
#include <malloc.h>
#include <coroutine>
#include <experimental/generator>
struct WDFQUEUE{};
namespace foo {
template <typename T>
class PoolAllocator final {
public:
using value_type = T;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
template <class U>
struct rebind {
using other = PoolAllocator<T>;
};
pointer allocate(size_t size) noexcept {
return static_cast<pointer>(malloc(size));
}
void deallocate(pointer ptr, [[maybe_unused]] size_t size) noexcept {
free(ptr);
}
};
template <typename T>
using Generator = std::experimental::generator<T, PoolAllocator<char>>;
class IteratedRequest final
{
public:
bool valid() const { return true; }
bool next(WDFQUEUE queue) { return true; }
};
Generator<IteratedRequest> IterateRequests(WDFQUEUE queue) {
IteratedRequest currentRequest;
while (currentRequest.next(queue)) {
if (!currentRequest.valid()) {
continue;
}
co_yield currentRequest;
}
}
}
C:\Users\kobyk\Documents\Stuff\ge>cl /kernel /nologo /std:c++latest /c ge.cpp
ge.cpp
ge.cpp(54): error C2980: C++ exception handling is not supported with /kernel
Expected behavior
Previously, generators with a non-throwing allocator worked with code built with /kernel.
Furthermore, removing the unhandled_exception() function added by the PR results in the code compiling successfully.
STL version
Microsoft Visual Studio Community 2019 Preview
Version 16.8.0 Preview 3.1
Additional context
Switching back to legacy coroutines (i.e., including <experimental/coroutine> instead of <coroutine> and adding /await to the compiler command line) also resolves the C2980 error.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!