public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110707] New: unused-but-set-variable in static lambda with deduced parameter
@ 2023-07-17 19:59 chris0cotter at gmail dot com
  2024-03-24 18:16 ` [Bug c++/110707] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: chris0cotter at gmail dot com @ 2023-07-17 19:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110707
           Summary: unused-but-set-variable in static lambda with deduced
                    parameter
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chris0cotter at gmail dot com
  Target Milestone: ---

With GCC-13.1 using `-std=c++20 -Wall`, the following code causes an
unused-but-set-variable warning for `f1` being unused.

https://godbolt.org/z/5vfEd7vr5

int foo() {
    static auto f1 = [](int a) { return a;}; // warning: variable 'f1' set but
not used [-Wunused-but-set-variable]
    static auto f2 = [](auto s) -> int { return f1(s); };
    return f2(0);
}

The warning disappears if I replace `auto s` with `int s`, or if I remove the
return type from the second lambda ` -> int`.

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

* [Bug c++/110707] unused-but-set-variable in static lambda with deduced parameter
  2023-07-17 19:59 [Bug c++/110707] New: unused-but-set-variable in static lambda with deduced parameter chris0cotter at gmail dot com
@ 2024-03-24 18:16 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-24 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-03-24
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2024-03-24 18:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17 19:59 [Bug c++/110707] New: unused-but-set-variable in static lambda with deduced parameter chris0cotter at gmail dot com
2024-03-24 18:16 ` [Bug c++/110707] " 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).