public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pdimov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104867] New: Base class matching ignores type of `auto` template parameter
Date: Thu, 10 Mar 2022 16:56:06 +0000	[thread overview]
Message-ID: <bug-104867-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2022-03-10 16:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 16:56 pdimov at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104867-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).