public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98450] New: Inconsistent Wunused-variable warning for std::array
@ 2020-12-26 19:24 maic23 at live dot de
2020-12-28 16:12 ` [Bug c++/98450] " maic23 at live dot de
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: maic23 at live dot de @ 2020-12-26 19:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98450
Bug ID: 98450
Summary: Inconsistent Wunused-variable warning for std::array
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: maic23 at live dot de
Target Milestone: ---
When using std::array in C++17 mode, -Wunused-variable behaves inconsistent:
$ cat /tmp/a.cpp
#include <array>
static constexpr std::array bay{9};
static constexpr std::array<int, 1> bax{9};
$ gcc -std=c++17 -Wall -S /tmp/a.cpp
/tmp/a.cpp:2:37: warning: ‘bay’ defined but not used [-Wunused-variable]
2 | static constexpr std::array bay{9};
| ^~~
Now, if the two lines are switched, there is no warning:
$ cat /tmp/b.cpp
#include <array>
static constexpr std::array<int, 1> bax{9};
static constexpr std::array bay{9};
$ gcc -std=c++17 -Wall -S /tmp/b.cpp
(no warning)
It makes it really hard to debug and fix this warning when it occurs only
sporadically.
The warning should probably not appear at all, because static const(expr)
variables are put in header files, but not used everywhere where the header
file is included in a cpp file.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/98450] Inconsistent Wunused-variable warning for std::array
2020-12-26 19:24 [Bug c++/98450] New: Inconsistent Wunused-variable warning for std::array maic23 at live dot de
@ 2020-12-28 16:12 ` maic23 at live dot de
2021-12-23 9:26 ` pinskia at gcc dot gnu.org
2023-04-11 16:12 ` gnu.ojxq8 at dralias dot com
2 siblings, 0 replies; 4+ messages in thread
From: maic23 at live dot de @ 2020-12-28 16:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98450
--- Comment #1 from maic <maic23 at live dot de> ---
As a temporary workaround to suppress the erroneous warning, `auto` can be
used:
$ cat /tmp/c.cpp
#include <array>
static constexpr auto bay = std::array{9};
static constexpr std::array<int, 1> bax{9};
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/98450] Inconsistent Wunused-variable warning for std::array
2020-12-26 19:24 [Bug c++/98450] New: Inconsistent Wunused-variable warning for std::array maic23 at live dot de
2020-12-28 16:12 ` [Bug c++/98450] " maic23 at live dot de
@ 2021-12-23 9:26 ` pinskia at gcc dot gnu.org
2023-04-11 16:12 ` gnu.ojxq8 at dralias dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-23 9:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98450
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to fail| |12.0
Ever confirmed|0 |1
Last reconfirmed| |2021-12-23
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/98450] Inconsistent Wunused-variable warning for std::array
2020-12-26 19:24 [Bug c++/98450] New: Inconsistent Wunused-variable warning for std::array maic23 at live dot de
2020-12-28 16:12 ` [Bug c++/98450] " maic23 at live dot de
2021-12-23 9:26 ` pinskia at gcc dot gnu.org
@ 2023-04-11 16:12 ` gnu.ojxq8 at dralias dot com
2 siblings, 0 replies; 4+ messages in thread
From: gnu.ojxq8 at dralias dot com @ 2023-04-11 16:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98450
maic <gnu.ojxq8 at dralias dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from maic <gnu.ojxq8 at dralias dot com> ---
Fixed in
# gcc --version
gcc (GCC) 13.0.1 20230404 (Red Hat 13.0.1-0)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-11 16:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-26 19:24 [Bug c++/98450] New: Inconsistent Wunused-variable warning for std::array maic23 at live dot de
2020-12-28 16:12 ` [Bug c++/98450] " maic23 at live dot de
2021-12-23 9:26 ` pinskia at gcc dot gnu.org
2023-04-11 16:12 ` gnu.ojxq8 at dralias 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).