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

            Bug ID: 104867
           Summary: Base class matching ignores type of `auto` template
                    parameter
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pdimov at gmail dot com
  Target Milestone: ---

The following program

```
enum class Foo
{
    A1
};

enum class Bar
{
    B1
};

template <auto EnumVal> struct enum_
{
};

template<class...> struct list {};

struct enum_type_map: list<enum_<Foo::A1>, int>, list<enum_<Bar::B1>, double>
{};

template<class V> V f( list<enum_<Bar::B1>, V> const& )
{
    return {};
}

int main()
{
    f( enum_type_map() );
}
```

yields

```
<source>: In function 'int main()':
<source>:26:6: error: no matching function for call to 'f(enum_type_map)'
   26 |     f( enum_type_map() );
      |     ~^~~~~~~~~~~~~~~~~~~
<source>:19:21: note: candidate: 'template<class V> V f(const
list<enum_<Bar::B1>, V>&)'
   19 | template<class V> V f( list<enum_<Bar::B1>, V> const& )
      |                     ^
<source>:19:21: note:   template argument deduction/substitution failed:
<source>:26:6: note:   'const list<enum_<Bar::B1>, V>' is an ambiguous base
class of 'enum_type_map'
   26 |     f( enum_type_map() );
      |     ~^~~~~~~~~~~~~~~~~~~
```

which is caused by `A1` and `B1` having the same value 0, even though their
types differ. (https://godbolt.org/z/3854zrY7x)

Clang successfully compiles the code (https://godbolt.org/z/eKEdf1zdo).

This is a distilled version of a bug report against `mp_map_find` from Mp11:
https://github.com/boostorg/mp11/issues/72

Reply via email to