This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/69672] Useless -Wenum-compare when comparing enum vaue against the same value in enum hack


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69672

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-05-18
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.3, 5.3.0, 6.1.0, 7.0
           Severity|normal                      |enhancement

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Unlike bug 69670 I think it makes sense to consider this change request for two
reasons: first, because when one of the enumerated types is anonymous it seems
like a good indication that its enumerators are intended to be used as poor
man's integer constants whose type doesn't matter, and second, because Clang
doesn't warn in this case.

$ cat u.cpp && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S
-Wall -Wextra -Wpedantic u.cpp
enum E { e };
enum { f = e };

int foo (E a)
{
  return a == f;
}
u.cpp: In function âint foo(E)â:
u.cpp:6:15: warning: comparison between âenum Eâ and âenum<anonymous>â
[-Wenum-compare]
   return a == f;
               ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]