<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55535>55535</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang 13/14 + libstdc++-12: issue with getting base constructor from std::function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jcelerier
      </td>
    </tr>
</table>

<pre>
    Hello,
consider the following code: https://gcc.godbolt.org/z/b1nKecWTc

It works fine with clang on libstdc++11, and with gcc 12 / libstdc++12.

However, with clang 13 and 14 + libstdc++12: the correct constructor isn't found ; it seems that unlike other paltform combos, the 

```

    template <
        typename Fn,
        std::enable_if_t<std::is_same_v<void, std::result_of_t<Fn(const int&)>>, int> = 0
    >
    effect(Fn&& fn)
        : base_t{[fn = std::forward<Fn>(fn)](auto&& ctx) -> future {
            fn(ctx);
            return {};
        }}
    {}
```
takes precedence in this case.

 

``` 
foo.cpp:39:19: error: no viable conversion from '(lambda at foo.cpp:39:23)' to 'lager::effect'
    lager::effect f = [ ] (auto&&) { return lager::future{}; };
                  ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/std_function.h:375:7: note: candidate inherited constructor not viable: no known conversion from '(lambda at foo.cpp:39:23)' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
      function(nullptr_t) noexcept
      ^
foo.cpp:13:19: note: constructor from base class 'function<lager::future (const int &)>' inherited here
    using base_t::base_t;
                  ^
foo.cpp:16:5: note: candidate constructor not viable: no known conversion from '(lambda at foo.cpp:39:23)' to 'const lager::effect &' for 1st argument
    effect(const effect&) = default;
    ^
foo.cpp:17:5: note: candidate constructor not viable: no known conversion from '(lambda at foo.cpp:39:23)' to 'lager::effect &&' for 1st argument
    effect(effect&&)      = default;
    ^
foo.cpp:25:5: note: candidate template ignored: requirement 'std::is_same_v<void, lager::future>' was not satisfied [with Fn = (lambda at foo.cpp:39:23)]
    effect(Fn&& fn)
    ^
foo.cpp:39:23: note: candidate template ignored: could not match 'auto (*)(type-parameter-0-0 &&)' against 'lager::effect'
    lager::effect f = [ ] (auto&&) { return lager::future{}; };
                      ^
1 error generated.
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNV1GP4jYQ_jXhxSJKHELYBx52bxdd1ddKfUSOMwHfGpvazrLXX98ZJ4SwcNerquqKjBNsz3i-mfE3prbN1_Vn0Nom_FOSPSfZo7TGqwYcC3tgrcWpkzI7Jm0DSfHI9iEcPb4kfINtJ2W6s01tdUit2-HIn_itc_MryN9_k73Gvv8lsJN1r561ygA7qbBnUgvUbA3TqvahkQl_wpbnaAsTpukX4RYs5wzVfljG06n6z_YEb-BIdKI7L6KifIHyTx_lCQ6BlNY5kIER8uA6GaxjypuEVwEd0KF8UjwxFZgHOHgUEYF1RqtXYBblHTsKHVrrDqjhUFtPNpDeqXnJMhvaZJDhJ8DhqEXA1cWny2ic-XoEIw7ANmYMznkOYVAMikdcUWvYqnYbUME4rPzWo-j2DQffrGrIpHHSge902NpehrSvInSmTEj4MuEPSfFCDYVoqHhB455ZdjGBJscf0LboPVRCmlB6yVpDOq4MJl_XwgNuWT0l5VNros7RJnTfSbimt4e2XvVKymd8FV2wg2oZ3nGYzcmotgudQ8ehwqu96NNGVHExBu923gHKmihbPd-soDFsF7z9snuRDOIVPDtiAkEDRgJ6DIOvPJOI9ipD7-fDMNpam8rjET1RoMGPOXUMnLOOXoxlb4oCTTmKWe4VHprW2QOmdYVAtTjUjWCC8vVKDy_IAbxiwdJSLXbghsQZolZdUN7MsjYGCcOFX3xOI0FRQLecHTmR7cMyepbdc_Dlk5Qv0cEvP6f1weCbzjsiLoVps0lT7JArloue4bB_Xy23y8X8KOdame59vjMdjiIF5Wl2lvjQKSN1h5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