public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109367] New: bogus -Wunused-function warning
@ 2023-04-01  1:41 f.heckenbach@fh-soft.de
  2023-04-01  1:48 ` [Bug c++/109367] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: f.heckenbach@fh-soft.de @ 2023-04-01  1:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109367
           Summary: bogus -Wunused-function warning
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f.heckenbach@fh-soft.de
  Target Milestone: ---

% cat test.cpp
using T = decltype ([]{});
struct S { static void f(T); };
void S::f(T) {}
% g++ --std=c++20 -Wall -c test.cpp
test.cpp:3:6: warning: 'static void S::f(T)' defined but not used
[-Wunused-function]
    3 | void S::f(T) {}
      |      ^

This happens with decltype of a lambda or a type containing such (in my actual
use case, a multimap with a comparator defined this way) in the function's
arguments or return type.

The warning is bogus since static member functions can be accessed from
elsewhere.

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

* [Bug c++/109367] bogus -Wunused-function warning
  2023-04-01  1:41 [Bug c++/109367] New: bogus -Wunused-function warning f.heckenbach@fh-soft.de
@ 2023-04-01  1:48 ` pinskia at gcc dot gnu.org
  2023-04-01  2:00 ` f.heckenbach@fh-soft.de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-01  1:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Please file a different bug with your full testcase as I think decltype of a
lamba is a type which has local linkage but I could be wrong.

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

* [Bug c++/109367] bogus -Wunused-function warning
  2023-04-01  1:41 [Bug c++/109367] New: bogus -Wunused-function warning f.heckenbach@fh-soft.de
  2023-04-01  1:48 ` [Bug c++/109367] " pinskia at gcc dot gnu.org
@ 2023-04-01  2:00 ` f.heckenbach@fh-soft.de
  2023-04-01  2:48 ` [Bug c++/109367] bogus -Wunused-function warning with decltype of a lambda as an argument pinskia at gcc dot gnu.org
  2024-04-13  8:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: f.heckenbach@fh-soft.de @ 2023-04-01  2:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Frank Heckenbach <f.heckenbach@fh-soft.de> ---
My full testcase consists of many includes files, libraries etc.

The type declarations (corresponding to the first two lines of the
stripped-down example) are in a header to be called from other translation
units, and the function implementation (the last line) in a cpp file, as usual.

So this means, decltype can't be used this way at all? If so, not a compiler
bug; but severely disappointed in the standard again, rendering a hopeful
feature mostly useless by too strict limitations. I hope it will be rectified
in C++38 or so ... :/

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

* [Bug c++/109367] bogus -Wunused-function warning with decltype of a lambda as an argument
  2023-04-01  1:41 [Bug c++/109367] New: bogus -Wunused-function warning f.heckenbach@fh-soft.de
  2023-04-01  1:48 ` [Bug c++/109367] " pinskia at gcc dot gnu.org
  2023-04-01  2:00 ` f.heckenbach@fh-soft.de
@ 2023-04-01  2:48 ` pinskia at gcc dot gnu.org
  2024-04-13  8:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-01  2:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually I think the bug is:
using T = decltype ([]{});

is broken with GCC. There are multiple testcases dealing with that even.

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

* [Bug c++/109367] bogus -Wunused-function warning with decltype of a lambda as an argument
  2023-04-01  1:41 [Bug c++/109367] New: bogus -Wunused-function warning f.heckenbach@fh-soft.de
                   ` (2 preceding siblings ...)
  2023-04-01  2:48 ` [Bug c++/109367] bogus -Wunused-function warning with decltype of a lambda as an argument pinskia at gcc dot gnu.org
@ 2024-04-13  8:20 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-13

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. GCC thinks the type is a local type and then marks S::f as being
local to that TU.

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

end of thread, other threads:[~2024-04-13  8:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01  1:41 [Bug c++/109367] New: bogus -Wunused-function warning f.heckenbach@fh-soft.de
2023-04-01  1:48 ` [Bug c++/109367] " pinskia at gcc dot gnu.org
2023-04-01  2:00 ` f.heckenbach@fh-soft.de
2023-04-01  2:48 ` [Bug c++/109367] bogus -Wunused-function warning with decltype of a lambda as an argument pinskia at gcc dot gnu.org
2024-04-13  8:20 ` 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).