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

            Bug ID: 94819
           Summary: [10 Regression] Inherited and constrained constructors
                    are "ambiguous" even if they aren't Pt. 2
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

Hi gcc-team,

a recent report of mine https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94549
fixed my reduced example, but my unreduced test case is still failing.

This is the second attempt at reducing my test case and this came out of it:

```c++
#include <utility>

template <typename T, typename U>
concept same_as = std::is_same_v<T, U>;

template <typename T, typename U>
concept convertible_to = std::is_convertible_v<T, U>;

template <typename... component_types>
struct alphabet_tuple_base
{
    template <typename type>
    static constexpr bool is_component = (same_as<type, component_types> ||
...);

    template <typename type>
    static constexpr bool is_indirect_component = !is_component<type> &&
(convertible_to<type, component_types> || ...);

    // commenting out constexpr works?!
    template <typename component_type>
        requires is_component<component_type>
    constexpr alphabet_tuple_base(component_type) {} 

    template <typename indirect_component_type>
        requires is_indirect_component<indirect_component_type>
    alphabet_tuple_base(indirect_component_type);
};

template <typename sequence_alphabet_t, typename structure_alphabet_t>
struct structured_rna : alphabet_tuple_base<sequence_alphabet_t,
structure_alphabet_t> {
  using base_type = alphabet_tuple_base<sequence_alphabet_t,
structure_alphabet_t>;
  using base_type::base_type;
};

struct dna4 {};
struct rna4 {
  rna4(dna4);
};
struct wuss51 {};

// commenting out any of these works?!
structured_rna<rna4, wuss51> t1{wuss51{}}; 
structured_rna<rna4, wuss51> t2{dna4{}};
structured_rna<rna4, wuss51> t3{wuss51{}};

```

https://godbolt.org/z/WVvSxb

Note that `is_component` and `is_indirect_component` are mutual exclusive, so
there isn't any ambiguity even if they don't subsume each other. 

This worked in gcc-9 with `-fconcepts` and apparently in msvc and clang, too.

```
> g++-git -std=c++2a

<source>:41:41: error: call of overloaded 'structured_rna(<brace-enclosed
initializer list>)' is ambiguous
   41 | structured_rna<rna4, wuss51> t3{wuss51{}}; // commenting out any of
these works?!
      |                                         ^
<source>:20:15: note: candidate: 'constexpr
alphabet_tuple_base<component_types>::alphabet_tuple_base(component_type) [with
component_type = wuss51; component_types = {rna4, wuss51}]'
   20 |     constexpr alphabet_tuple_base(component_type) {} // commenting out
constexpr works?!
      |               ^~~~~~~~~~~~~~~~~~~
<source>:30:20: note:   inherited here
   30 |   using base_type::base_type;
      |                    ^~~~~~~~~
<source>:24:5: note: candidate:
'alphabet_tuple_base<component_types>::alphabet_tuple_base(indirect_component_type)
[with indirect_component_type = indirect_component_type; component_types =
{rna4, wuss51}]'
   24 |     alphabet_tuple_base(indirect_component_type);
      |     ^~~~~~~~~~~~~~~~~~~
<source>:30:20: note:   inherited here
   30 |   using base_type::base_type;
      |                    ^~~~~~~~~
<source>:28:8: note: candidate: 'constexpr structured_rna<rna4,
wuss51>::structured_rna(const structured_rna<rna4, wuss51>&)'
   28 | struct structured_rna : alphabet_tuple_base<sequence_alphabet_t,
structure_alphabet_t> {
      |        ^~~~~~~~~~~~~~
<source>:28:8: note: candidate: 'constexpr structured_rna<rna4,
wuss51>::structured_rna(structured_rna<rna4, wuss51>&&)'
Compiler returned: 1
```

Reply via email to