https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83942
Bug ID: 83942
Summary: False -Wunused-but-set-variable when const scoped enum
is cast to int
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: sbergman at redhat dot com
Target Milestone: ---
With recent trunk "g++ (GCC) 8.0.1 20180119 (experimental)" towards GCC 8:
> $ cat test.cc
> enum class E { E1 };
> int main() {
> E const e = E::E1;
> return static_cast<int>(e);
> }
>
> $ g++ -Wall test.cc
> test.cc: In function ‘int main()’:
> test.cc:3:13: warning: variable ‘e’ set but not used
> [-Wunused-but-set-variable]
> E const e = E::E1;
> ^
(which hit me when trying to build LibreOffice)