public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104867] New: Base class matching ignores type of `auto` template parameter
@ 2022-03-10 16:56 pdimov at gmail dot com
  2022-03-11 14:40 ` [Bug c++/104867] " ppalka at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pdimov at gmail dot com @ 2022-03-10 16:56 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-16 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 16:56 [Bug c++/104867] New: Base class matching ignores type of `auto` template parameter pdimov at gmail dot com
2022-03-11 14:40 ` [Bug c++/104867] " ppalka at gcc dot gnu.org
2023-12-13 20:57 ` cvs-commit at gcc dot gnu.org
2023-12-16 17:15 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).