https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104177

--- Comment #20 from David Ledger <davidledger at live dot com.au> ---
Yeah, your right. I had noticed the mistake and reduced the code without
thinking enough:

```CPP
#include <coroutine>
#include <cstddef>
#include <cstdint>
#include <cassert>
using namespace std;

struct overaligned { alignas(128) char padding[128]; };
alignas(2048) static char buffer[2048];

template <typename a>
struct b
{
    struct promise_type
    {
        void * operator new(size_t) { return
&buffer[alignof(std::max_align_t)]; }
        b<a> get_return_object() { return b<a>{
std::coroutine_handle<promise_type>::from_promise(*this) }; }
        void unhandled_exception() {}
        suspend_always initial_suspend() { return {}; }
        suspend_always final_suspend() noexcept { return {}; }
        suspend_always yield_value(a v) { return {}; }
    };
    std::coroutine_handle<promise_type> handle;
};

b<std::uintptr_t> c()
{
    overaligned temp{};
    auto addr = reinterpret_cast<std::uintptr_t>(&temp);
    assert((addr % alignof(overaligned)) == 0);
    co_yield addr;
}

int main() {
    auto f = c();
    f.handle.resume();
}
```
This will trigger the assert above, you should see:
`Assertion failed: (addr % alignof(overaligned)) == 0, file
F:/Files/Git/hz/test/Scratch/main.cpp, line 29`

Reply via email to