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

            Bug ID: 89851
           Summary: [Regression] std::variant comparison operators violate
                    [variant.relops]
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

The following function should return `false` according to [variant.relops]:


#include <variant>

using V = std::variant<int, int>;
bool test1() { 
    V v1{std::in_place_index<0>, 0};
    V v2{std::in_place_index<1>, 0};
    return v1 == v2;
}


std::variant in GCC-8 was returning `false`, however the variant from GCC-9
returns `true`.


This could be quickly fixed by comparing indexes at the start of each operator.
Another way of fixing is to pass integral_constants instead of types into the
__do_visit function.

Reply via email to