Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stl/inc/generator
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private:
}

static void __stdcall _Dealloc_delete(void* const _Ptr, const size_t _Size) noexcept {
::operator delete[](_Ptr, _Size + sizeof(_Dealloc_fn));
::operator delete(_Ptr, _Size + sizeof(_Dealloc_fn));
}

template <class _ProtoAlloc>
Expand Down Expand Up @@ -164,7 +164,7 @@ private:

public:
static void* operator new(const size_t _Size) { // default: new/delete
void* const _Ptr = ::operator new[](_Size + sizeof(_Dealloc_fn));
void* const _Ptr = ::operator new(_Size + sizeof(_Dealloc_fn));
const _Dealloc_fn _Dealloc = _Dealloc_delete;
_CSTD memcpy(static_cast<char*>(_Ptr) + _Size, &_Dealloc, sizeof(_Dealloc_fn));
return _Ptr;
Expand Down
11 changes: 11 additions & 0 deletions tests/std/tests/P2502R2_generator_promise/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <coroutine>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <forward_list>
#include <generator>
#include <list>
Expand All @@ -22,6 +23,16 @@

using namespace std;

#pragma warning(disable : 28251) // Inconsistent annotation for 'new[]': this instance has no annotations.

void* operator new[](size_t) {
abort();
}

void operator delete[](void*) noexcept {
abort();
}

template <class Promise, class... Args>
concept HasOperatorNew = requires(Args&&... args) {
{ Promise::operator new(forward<Args>(args)...) } -> same_as<void*>;
Expand Down