https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80351
Pokechu22 <pokechu022+gccbugzilla at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pokechu022+gccbugzilla@gmai | |l.com --- Comment #3 from Pokechu22 <pokechu022+gccbugzilla at gmail dot com> --- Still an issue in GCC 11.2. Here are some additional examples: https://godbolt.org/z/hvEs6bb95 https://godbolt.org/z/674seG3bn https://godbolt.org/z/6esEs1fsr https://godbolt.org/z/s8eqsnzP9 https://godbolt.org/z/1TjnP6GeG https://godbolt.org/z/czefeKWsf The use of an enum class isn't needed; the issue also happens with int. In GCC 7.1+, marking warn as [[maybe_unused]] removes the warning (it doesn't get shifted to no_warn); GCC 6.4- give an additional warning that "'maybe_unused' attribute directive ignored" (it may not have been implemented then). Explicitly using std::initializer_list<int> instead of auto resolves the issue. In GCC 9.2+, only warn needs to be changed to have an explicit type (no_warn can remain as auto without a warning being generated), but in GCC 9.1-, the first use of auto will generate the warning (meaning no_warn will generate a warning unless it too is changed). If different types are used, then one warning is generated for each type (e.g. {1, 2} and {1u, 2u} each generate one warning). The behavior of only one warning being generated started in GCC 4.8.1+; multiple warnings were generated in 4.7.4-.