diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine index 6e1cf141579..2b635b982e0 100644 --- a/libstdc++-v3/include/std/coroutine +++ b/libstdc++-v3/include/std/coroutine @@ -249,16 +249,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; - 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 <> @@ -284,7 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // [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; } @@ -292,13 +282,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION private: friend coroutine_handle noop_coroutine() noexcept; - coroutine_handle() = default; + struct __frame + { + static void __dummy_resume_destroy() { } - void* _M_fr_ptr = (void*) &__noop_coro_fr; + void (*__r)() = __dummy_resume_destroy; + void (*__d)() = __dummy_resume_destroy; + struct noop_coroutine_promise __p; + }; + + static __frame _S_fr; + + explicit coroutine_handle() noexcept = default; + + void* _M_fr_ptr = &_S_fr; }; using noop_coroutine_handle = coroutine_handle; + inline noop_coroutine_handle::__frame + noop_coroutine_handle::_S_fr{}; + inline noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); diff --git a/libstdc++-v3/testsuite/18_support/coroutines/95917.cc b/libstdc++-v3/testsuite/18_support/coroutines/95917.cc new file mode 100644 index 00000000000..5c9cf57e001 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/coroutines/95917.cc @@ -0,0 +1,31 @@ +// 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 +// . + +// { 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 + +// PR libstdc++/95917 + +void +test01() +{ + std::coroutine_handle<> h; +}