public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96311] New: false positive for -Wunused-but-set-variable (const/constexpr identifier used in generic lambda)
@ 2020-07-24 15:36 tilkax at gmail dot com
  2020-07-27  7:11 ` [Bug c++/96311] " marxin at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: tilkax at gmail dot com @ 2020-07-24 15:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96311
           Summary: false positive for -Wunused-but-set-variable
                    (const/constexpr identifier used in generic lambda)
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tilkax at gmail dot com
  Target Milestone: ---

Using gcc version 11.0.0 20200723, this code:

void foo()
{
    constexpr int used = 0;
    [](auto unused)
    {
        return used;
    };
}

triggers an incorrect warning:

<source>:3:19: warning: variable 'used' set but not used
[-Wunused-but-set-variable]
    3 |     constexpr int used = 0;
      |                   ^~~~

It doesn't matter whether the lambda is called but it does need to be a generic
lambda to trigger the incorrect warning.

Also, both the lambda parameter as well as the lambda itself are unused here
but don't trigger any warnings :/

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

end of thread, other threads:[~2022-05-13 17:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 15:36 [Bug c++/96311] New: false positive for -Wunused-but-set-variable (const/constexpr identifier used in generic lambda) tilkax at gmail dot com
2020-07-27  7:11 ` [Bug c++/96311] " marxin at gcc dot gnu.org
2020-07-27  7:40 ` tilkax at gmail dot com
2020-07-27 10:09 ` [Bug c++/96311] [8/9/10/11 Regression] " jakub at gcc dot gnu.org
2020-07-27 10:17 ` jakub at gcc dot gnu.org
2021-02-11 15:25 ` jakub at gcc dot gnu.org
2021-03-10 17:29 ` hewillk at gmail dot com
2021-04-05 20:04 ` jason at gcc dot gnu.org
2021-04-05 21:27 ` cvs-commit at gcc dot gnu.org
2021-04-05 21:29 ` [Bug c++/96311] [8/9/10 " jason at gcc dot gnu.org
2021-05-14  9:53 ` [Bug c++/96311] [9/10 " jakub at gcc dot gnu.org
2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
2021-06-01  8:18 ` rguenth at gcc dot gnu.org
2022-05-13 17:41 ` [Bug c++/96311] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 17:45 ` jason 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).