public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function
@ 2020-06-22  9:14 gleb at scylladb dot com
  2020-06-23  9:09 ` [Bug c++/95813] " iains at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gleb at scylladb dot com @ 2020-06-22  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95813
           Summary: Making static member function a coroutine may cause
                    "defined but not used" warning for destroy(frame*)
                    function
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gleb at scylladb dot com
  Target Milestone: ---

Compiling the code below with -Wall emits:

warn.cc:37:5: warning: ^Xגvoid
xxx::_ZN3xxx4funcEv.destroy(xxx::func()::_ZN3xxx4funcEv.frame*)^Yג defined but
not used [-Wunused-function]

and if foo() is uncommented the code compiles fine.

If should be OK to have the static member function in a header without getting
the warning.

#include <coroutine>
#include <functional>
#include <optional>
#include <cassert>

template <typename T>
class lazy {
    T _v = 0;
public:
    lazy() {}
    bool await_ready() {return true;}
    void await_suspend(auto x) noexcept {}
    T await_resume() { return _v; }
};

namespace std {

template <typename T, typename... Args>
struct coroutine_traits<lazy<T>, Args...> {
    struct promise_type {
        suspend_always initial_suspend() const { return {}; }
        suspend_always final_suspend() const { return {}; }
        void return_value(T val) {}
        lazy<T> get_return_object() {
            return lazy<T>();
        }
        void unhandled_exception() {
            std::terminate();
        }
    };
};
}

struct xxx {
    static lazy<int> func() {
        co_return 1;
    }
};

#if 0
lazy<int> foo() {
    co_return co_await xxx::func();
}
#endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/95813] Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function
  2020-06-22  9:14 [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function gleb at scylladb dot com
@ 2020-06-23  9:09 ` iains at gcc dot gnu.org
  2020-06-24 20:06 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-23  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |iains at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-06-23
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |10.2

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
thanks for the report.
this is most likely the same underlying cause as PR95518 (for which I have a
fix in progress).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/95813] Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function
  2020-06-22  9:14 [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function gleb at scylladb dot com
  2020-06-23  9:09 ` [Bug c++/95813] " iains at gcc dot gnu.org
@ 2020-06-24 20:06 ` cvs-commit at gcc dot gnu.org
  2020-06-28  8:59 ` cvs-commit at gcc dot gnu.org
  2020-06-28  9:06 ` iains at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-24 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:1e5da6a02fec8aa84bb00966282f420cb70fe4f0

commit r11-1640-g1e5da6a02fec8aa84bb00966282f420cb70fe4f0
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Jun 24 18:48:33 2020 +0100

    coroutines: Copy attributes to the outlined functions [PR95518,PR95813]

    We had omitted the copying of function attributes, we now copy
    the used, alignment, section values from the original decal and
    the complete set of function attributes.  It is likely that
    some function attributes don't really make sense for coroutines,
    but that can be disgnosed separately. Also mark the outlined
    functions as artificial, since they are; some diagnostic
    processing tests this.

    gcc/cp/ChangeLog:

            PR c++/95518
            PR c++/95813
            * coroutines.cc (act_des_fn): Copy function
            attributes onto the outlined coroutine helpers.

    gcc/testsuite/ChangeLog:

            PR c++/95518
            PR c++/95813
            * g++.dg/coroutines/pr95518.C: New test.
            * g++.dg/coroutines/pr95813.C: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/95813] Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function
  2020-06-22  9:14 [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function gleb at scylladb dot com
  2020-06-23  9:09 ` [Bug c++/95813] " iains at gcc dot gnu.org
  2020-06-24 20:06 ` cvs-commit at gcc dot gnu.org
@ 2020-06-28  8:59 ` cvs-commit at gcc dot gnu.org
  2020-06-28  9:06 ` iains at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-28  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:c3bf482a0e59b9da925b382387686656c3d8839f

commit r10-8380-gc3bf482a0e59b9da925b382387686656c3d8839f
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun Jun 28 09:48:33 2020 +0100

    coroutines: Copy attributes to the outlined functions [PR95518,PR95813]

    We had omitted the copying of function attributes, we now copy
    the used, alignment, section values from the original decal and
    the complete set of function attributes.  It is likely that
    some function attributes don't really make sense for coroutines,
    but that can be disgnosed separately. Also mark the outlined
    functions as artificial, since they are; some diagnostic
    processing tests this.

    gcc/cp/ChangeLog:

            PR c++/95518
            PR c++/95813
            * coroutines.cc (act_des_fn): Copy function
            attributes onto the outlined coroutine helpers.

    gcc/testsuite/ChangeLog:

            PR c++/95518
            PR c++/95813
            * g++.dg/coroutines/pr95518.C: New test.
            * g++.dg/coroutines/pr95813.C: New test.

    (cherry picked from commit 1e5da6a02fec8aa84bb00966282f420cb70fe4f0)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/95813] Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function
  2020-06-22  9:14 [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function gleb at scylladb dot com
                   ` (2 preceding siblings ...)
  2020-06-28  8:59 ` cvs-commit at gcc dot gnu.org
@ 2020-06-28  9:06 ` iains at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-28  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
fixed for master and 10.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-28  9:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22  9:14 [Bug c++/95813] New: Making static member function a coroutine may cause "defined but not used" warning for destroy(frame*) function gleb at scylladb dot com
2020-06-23  9:09 ` [Bug c++/95813] " iains at gcc dot gnu.org
2020-06-24 20:06 ` cvs-commit at gcc dot gnu.org
2020-06-28  8:59 ` cvs-commit at gcc dot gnu.org
2020-06-28  9:06 ` iains at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).