[Bug c/16186] gcc should have an option to warn about enumerations with duplicate values
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 13 13:44:53 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16186
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to trashyankes from comment #7)
> Should be way to disable/enable this warning per `enum`?
> Like:
>
> ```
> enum [[gnu::enum_unique]] X
> {
> I = 1,
> J = 2,
> };
>
> enum [[gnu::enum_not_unique]] Y
> {
> K = 1,
> L = 1,
> };
>
> ```
No, it should warn solely if enumerator gets implicitly assigned value of some
other enumerator. After all, the clang wording also mentions that:
element 'D' has been implicitly assigned 5 which another element has been
assigned [-Wduplicate-enum]
If there is = value for it, we should never warn, that is most likely
completely intentional.
Of course, we should use better wording, because we should talk about
enumerators, not elements...
More information about the Gcc-bugs
mailing list