{
};
- void __dummy_resume_destroy() __attribute__((__weak__));
- void __dummy_resume_destroy() {}
-
- struct __noop_coro_frame
- {
- void (*__r)() = __dummy_resume_destroy;
- void (*__d)() = __dummy_resume_destroy;
- struct noop_coroutine_promise __p;
- } __noop_coro_fr __attribute__((__weak__));
-
// 17.12.4.1 Class noop_coroutine_promise
/// [coroutine.promise.noop]
template <>
// [coroutine.handle.noop.promise], promise access
noop_coroutine_promise& promise() const noexcept
- { return __noop_coro_fr.__p; }
+ { return _S_fr.__p; }
// [coroutine.handle.noop.address], address
constexpr void* address() const noexcept { return _M_fr_ptr; }
private:
friend coroutine_handle noop_coroutine() noexcept;
- coroutine_handle() = default;
+ struct __frame
+ {
+ static void __dummy_resume_destroy() { }
+
+ void (*__r)() = __dummy_resume_destroy;
+ void (*__d)() = __dummy_resume_destroy;
+ struct noop_coroutine_promise __p;
+ };
+
+ static __frame _S_fr;
- void* _M_fr_ptr = (void*) &__noop_coro_fr;
+ explicit coroutine_handle() noexcept = default;
+
+ void* _M_fr_ptr = &_S_fr;
};
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
+ inline noop_coroutine_handle::__frame
+ noop_coroutine_handle::_S_fr{};
+
inline noop_coroutine_handle noop_coroutine() noexcept
{
return noop_coroutine_handle();
--- /dev/null
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a -g0" }
+// { dg-do compile { target c++2a } }
+// { dg-final { scan-assembler-not "dummy_resume_destroy" } }
+// { dg-final { scan-assembler-not "noop_coro" } }
+
+#include <coroutine>
+
+// PR libstdc++/95917
+
+void
+test01()
+{
+ std::coroutine_handle<> h;
+}