Bug 87404 - Implement -Wenum-compare and -Wenum-compare-switch
Summary: Implement -Wenum-compare and -Wenum-compare-switch
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 87983 (view as bug list)
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2018-09-24 10:31 UTC by Martin Liška
Modified: 2022-04-14 19:41 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-09-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2018-09-24 10:31:40 UTC
As I wrote to Martin Jambor privately, the warning found a real issue:

/home/marxin/Programming/gcc/gcc/omp-grid.c:1063:15:Semantic Issue: comparison of two values with different enumeration types in switch statement ('enum tree_code' and 'omp_clause_code'): -Wenum-compare-switch
Comment 1 Martin Liška 2018-09-24 10:32:53 UTC
It comes from Clang, where there's no documentation, only a warning message:

-Wenum-compare: comparison of two values with different enumeration types
-Wenum-compare-switch: comparison of two values with different enumeration types in switch statement
Comment 2 Eric Gallager 2018-09-30 01:05:24 UTC
There are lots of open bugs that this could be a dup of, see for example: 
- bug 52763
- bug 78736 
- bug 69672
Comment 3 Jakub Jelinek 2019-03-08 14:25:22 UTC
Marek, would you like to implement this for GCC 10?
Comment 4 Marek Polacek 2019-03-08 14:56:06 UTC
I can try, sure.
Comment 5 Eric Gallager 2019-06-08 04:45:45 UTC
(In reply to Jakub Jelinek from comment #3)
> Marek, would you like to implement this for GCC 10?

(In reply to Marek Polacek from comment #4)
> I can try, sure.

It's GCC 10 now.
Comment 6 Marek Polacek 2020-10-28 15:40:33 UTC
My changes for P1120R0 will partially handle this, I think.  (I haven't posted it yet.)
Comment 7 Eric Gallager 2022-04-10 22:03:06 UTC
*** Bug 87983 has been marked as a duplicate of this bug. ***
Comment 8 Ævar Arnfjörð Bjarmason 2022-04-14 07:41:03 UTC
Eric: I filed bug 87983. I think it makes sense to mark it as a duplicate only if this one covers both C and C++, right now the "component" for this one is C++.

As bug 87983 notes in passing C does not have first-class enums, so implementing this will presumably be a bit harder than C++, and .
Comment 9 Eric Gallager 2022-04-14 17:57:24 UTC
(In reply to Ævar Arnfjörð Bjarmason from comment #8)
> Eric: I filed bug 87983. I think it makes sense to mark it as a duplicate
> only if this one covers both C and C++, right now the "component" for this
> one is C++.
> 
> As bug 87983 notes in passing C does not have first-class enums, so
> implementing this will presumably be a bit harder than C++, and .

My understanding was that this bug would cover both C and C++, as I'm pretty sure I've seen this clang warning in plain-C code before, too (and there's no component for the code shared by the C family of languages, which is where I'd assume this would be implemented)
Comment 10 Ævar Arnfjörð Bjarmason 2022-04-14 19:41:20 UTC
Thanks, just clarifying. I saw this one was in the C++ component unlike the
other one.

On Thu, Apr 14, 2022, 19:57 egallager at gcc dot gnu.org <
gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87404
>
> --- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> ---
> (In reply to Ævar Arnfjörð Bjarmason from comment #8)
> > Eric: I filed bug 87983. I think it makes sense to mark it as a duplicate
> > only if this one covers both C and C++, right now the "component" for
> this
> > one is C++.
> >
> > As bug 87983 notes in passing C does not have first-class enums, so
> > implementing this will presumably be a bit harder than C++, and .
>
> My understanding was that this bug would cover both C and C++, as I'm
> pretty
> sure I've seen this clang warning in plain-C code before, too (and there's
> no
> component for the code shared by the C family of languages, which is where
> I'd
> assume this would be implemented)
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.