public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joeloser at fastmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105842] New: rejects-valid: static member function overload set constrained by concepts for class template results in ambiguous call
Date: Fri, 03 Jun 2022 21:04:44 +0000	[thread overview]
Message-ID: <bug-105842-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105842
           Summary: rejects-valid: static member function overload set
                    constrained by concepts for class template results in
                    ambiguous call
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joeloser at fastmail dot com
  Target Milestone: ---

In the following snippet,

```
#include <concepts>
#include <cstddef>

template<class>
struct S {
  static constexpr auto f(const std::unsigned_integral auto value) ->
std::size_t {
    return {};
  }
  static constexpr auto f(const std::signed_integral auto value) -> std::size_t
{
    return f(static_cast<std::size_t>(value));
  }
};
```

The second `f` overload results in a compilation error:

```
error: call of overloaded ‘f(std::size_t)’ is ambiguous
... list of the two candidates
```

This appears to be a GCC bug, but only if S is a class template (regardless of
whether the template parameter list is a type or a non-type). Note that clang
trunk compiles the code fine as-is. If `S` is a class and not a class template,
then GCC accepts the code.

See it live at https://godbolt.org/z/oddxEWGMv

             reply	other threads:[~2022-06-03 21:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 21:04 joeloser at fastmail dot com [this message]
2022-06-06 12:39 ` [Bug c++/105842] " ppalka at gcc dot gnu.org
2022-07-01 12:22 ` ppalka at gcc dot gnu.org
2022-07-13 18:03 ` cvs-commit at gcc dot gnu.org
2022-07-13 18:05 ` ppalka at gcc dot gnu.org
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:51 ` ppalka at gcc dot gnu.org
2022-07-27 21:02 ` joeloser at fastmail dot com

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-105842-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).