Quantcast
Viewing all articles
Browse latest Browse all 22014

Unresolved overloaded function type in gcc

I am trying to pass a function template as an argument to another function as seen in the example below.

#include <iostream>

template <typename T>
decltype(auto) foo(T t)
{
    return t;
}

template <typename Fn, typename T>
decltype(auto) bar(Fn fn, T t)
{
    return fn(t);
}

int main()
{
    int arg = 0;

    std::cout << bar(foo<decltype(arg)>, arg) << std::endl;

    return 0;
}

While this works in clang 9.0 and msvc v19.24 it fails with gcc 9.2

gcc output:

no matching function for call to 'bar(<unresolved overloaded function type>, int&)' std::cout << bar(foo<decltype(arg)>, arg) << std::endl;

Is this a bug in gcc? Also can i circumvent this somehow in gcc?

Godbolt link: https://godbolt.org/z/oCChAT


Viewing all articles
Browse latest Browse all 22014

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>