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++/69670] New: Useless -Wenum-compare when comparing parallel enums in static_assert


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

            Bug ID: 69670
           Summary: Useless -Wenum-compare when comparing parallel enums
                    in static_assert
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wipedout at yandex dot ru
  Target Milestone: ---

I'm trying this on http://gcc.godbolt.org/ the version is "x86 gcc 5.3.0", the
options line is "-O3 -Wall -std=c++11" The code is as follows:

enum One {
  One_Magic
};

enum Two {
  Two_Magic
};

void test()
{
  static_assert( One_Magic == Two_Magic, "");
}

I get "warning: comparison between 'enum One' and 'enum Two' [-Wenum-compare]"
which is completely useless. The intent is to check that two parallel enum
elements have identical values. If they have identical values - the user is
happy, no problem. If they don't have identical values then static_assert fails
and this is impossible to ignore.

Same goes for pre-c++11 implementations of "static assert" (one is with an
array typedef and the other is with a template and a specialization thereof).

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