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

            Bug ID: 121351
           Summary: [15/16 Regression] Ambiguous resolution of constrained
                    overloads imported from base class
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: moncef.mechri at gmail dot com
  Target Milestone: ---

Consider the following code:

#include <concepts> 

template<class D>
struct Base {
    void FooIntegral() { static_cast<D*>(this)->Foo(42); }

    void Foo(std::integral auto a) {}
};

struct Derived : Base<Derived> {
    using Base::Foo;

    void Foo(std::integral auto a) {}
};

int main() {
    Derived d;
    d.FooIntegral();
}


This code is accepted by GCC < 15, clang 20.1.0, MSVC 19, and EDG 6.7 (in GNU
mode)

However, GCC 15 and trunk reject this code with the following error:

<source>: In instantiation of 'void Base<D>::FooIntegral() [with D = Derived]':
<source>:18:18:   required from here
   18 |     d.FooIntegral();
      |     ~~~~~~~~~~~~~^~
<source>:5:52: error: call of overloaded 'Foo(int)' is ambiguous
    5 |     void FooIntegral() { static_cast<D*>(this)->Foo(42); }
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
<source>:5:52: note: there are 2 candidates
<source>:7:10: note: candidate 1: 'void Base<D>::Foo(auto:1) [with auto:1 =
int; D = Derived]'
    7 |     void Foo(std::integral auto a) {}
      |          ^~~
<source>:13:10: note: candidate 2: 'void Derived::Foo(auto:2) [with auto:2 =
int]'
   13 |     void Foo(std::integral auto a) {}
      |          ^~~

Demo: https://godbolt.org/z/1v9czGEf8

I also noticed that the error disappears if I remove mentions of std::integral
in the above code.

Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119859

Reply via email to