This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84221] New: spurious -Wmaybe-uninitialized warning on a variable of a template type declared unused
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 05 Feb 2018 23:10:59 +0000
- Subject: [Bug c++/84221] New: spurious -Wmaybe-uninitialized warning on a variable of a template type declared unused
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84221
Bug ID: 84221
Summary: spurious -Wmaybe-uninitialized warning on a variable
of a template type declared unused
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
As Jason points out in
https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00197.html, issuing
-Wunused-variable for definition of the local 'a' in the test case below is a
false positive:
$ cat y.C && gcc -O2 -S -Wall -Wextra y.C
template <class T> struct [[gnu::unused]] A { };
template <> struct A<int> { };
void f (void)
{
A<int> a; // shouldn't warn
}
y.C: In function ‘void f()’:
y.C:6:10: warning: unused variable ‘a’ [-Wunused-variable]
A<int> a; // shouldn't warn
^