public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99361] New: "unused variable" warning on a used variable in template lambda
@ 2021-03-03 14:54 hewillk at gmail dot com
  2021-03-03 17:24 ` [Bug c++/99361] " mpolacek at gcc dot gnu.org
  2021-03-10 17:29 ` hewillk at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: hewillk at gmail dot com @ 2021-03-03 14:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99361
           Summary: "unused variable" warning on a used variable in
                    template lambda
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

The following code:

auto f() {
  const auto x = 1;
  return [] (auto) { return x; };
}

will emit unused variable warnings with "-std=c++20 -Wall" flags:

<source>: In function 'auto f()':
<source>:2:14: warning: variable 'x' set but not used
[-Wunused-but-set-variable]
    2 |   const auto x = 1;
      |     

godbolt: https://godbolt.org/z/d54j4G

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

end of thread, other threads:[~2021-03-10 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 14:54 [Bug c++/99361] New: "unused variable" warning on a used variable in template lambda hewillk at gmail dot com
2021-03-03 17:24 ` [Bug c++/99361] " mpolacek at gcc dot gnu.org
2021-03-10 17:29 ` hewillk at gmail dot com

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).