public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type
@ 2022-05-11 10:37 redbeard0531 at gmail dot com
  2022-10-30 20:10 ` [Bug c++/105560] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: redbeard0531 at gmail dot com @ 2022-05-11 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105560
           Summary: Spurious -Wunused-local-typedefs warning on a typedef
                    used on returned type
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redbeard0531 at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/zcY11ezev

#include <type_traits>
#include <utility>

template <typename F>
typename F::Out call(F&& fun) {
    typename F::Out var = fun(1);
    return var;
}

void test() {
    // Fill builder with bson-encoded elements from view.
    auto decorateLambda = [](auto&& lambda) {
        using Lambda = std::remove_reference_t<decltype(lambda)>;
        struct DecoratedLambda : Lambda {
            using Out = bool;
        };
        return DecoratedLambda{std::forward<decltype(lambda)>(lambda)};
    };
    call(decorateLambda([&](auto&& value) {
        (void)(value);
        return true;
    }));
}

With -O2 -std=c++20 -Wall:

<source>: In lambda function:
<source>:15:19: warning: typedef 'using
test()::<lambda(auto:1&&)>::DecoratedLambda::Out = bool' locally defined but
not used [-Wunused-local-typedefs]
   15 |             using Out = bool;
      |                   ^~~
Compiler returned: 0


However, DecoratedLambda::Out *is* used by call(), both in the signature and in
the body. Perhaps the issue is that typedefs in local types that are returned
(or are reachable from returned types) shouldn't be considered "local"?

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

* [Bug c++/105560] Spurious -Wunused-local-typedefs warning on a typedef used on returned type
  2022-05-11 10:37 [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type redbeard0531 at gmail dot com
@ 2022-10-30 20:10 ` pinskia at gcc dot gnu.org
  2022-10-30 20:11 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-30 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-10-30
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. Reduced testcase without lambdas:
template <typename F>
bool call(F&&) {
    typename F::Out var = false;
    return var;
}
bool test() {
    struct localc  {
        using Out = bool;
    };
    return call(localc{});
}

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

* [Bug c++/105560] Spurious -Wunused-local-typedefs warning on a typedef used on returned type
  2022-05-11 10:37 [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type redbeard0531 at gmail dot com
  2022-10-30 20:10 ` [Bug c++/105560] " pinskia at gcc dot gnu.org
@ 2022-10-30 20:11 ` pinskia at gcc dot gnu.org
  2022-10-30 20:12 ` pinskia at gcc dot gnu.org
  2022-10-30 20:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-30 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.8.1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, it used not to warn in GCC 4.7.1 but C++11 was not fully implemented until
4.8 so I don't think this could be considered a regression.

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

* [Bug c++/105560] Spurious -Wunused-local-typedefs warning on a typedef used on returned type
  2022-05-11 10:37 [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type redbeard0531 at gmail dot com
  2022-10-30 20:10 ` [Bug c++/105560] " pinskia at gcc dot gnu.org
  2022-10-30 20:11 ` pinskia at gcc dot gnu.org
@ 2022-10-30 20:12 ` pinskia at gcc dot gnu.org
  2022-10-30 20:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-30 20:12 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=61596

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect this is basically PR 61596 .

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

* [Bug c++/105560] Spurious -Wunused-local-typedefs warning on a typedef used on returned type
  2022-05-11 10:37 [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type redbeard0531 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-10-30 20:12 ` pinskia at gcc dot gnu.org
@ 2022-10-30 20:13 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-30 20:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes this is a dup of bug 61596.

*** This bug has been marked as a duplicate of bug 61596 ***

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

end of thread, other threads:[~2022-10-30 20:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 10:37 [Bug c++/105560] New: Spurious -Wunused-local-typedefs warning on a typedef used on returned type redbeard0531 at gmail dot com
2022-10-30 20:10 ` [Bug c++/105560] " pinskia at gcc dot gnu.org
2022-10-30 20:11 ` pinskia at gcc dot gnu.org
2022-10-30 20:12 ` pinskia at gcc dot gnu.org
2022-10-30 20:13 ` pinskia 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).