Skip to content

"Recommended" way of binding specific function overloads doesn't work on clang 14 #612

Description

@totalgee
  • Compiler Used: clang 14.0
  • Operating System: Ubuntu 22.04.2 LTS
  • Architecture (ARM/x86/32bit/64bit/etc): x64

Expected Behavior

Previously, I could bind overloaded functions and methods with the fun<> template (preferred method), but now the only thing that works is using static_cast (aka alternative method).

Actual Behavior

A compiler error message similar to:

/home/various_dirs/src/scripting.cpp:1117:35: error: no matching function for call to 'fun'

Minimal Example to Reproduce Behavior

For a function (in a namespace ci) that has two overloads, like this:

std::vector<std::string> split( const std::string &str, char separator, bool compress = true );
std::vector<std::string> split( const std::string &str, const std::string &separators, bool compress = true );

Binding in ChaiScript like this:

    m->add(fun<std::vector<string>(string const&, string const&, bool)>(&ci::split), "split");

gives the above-mentioned compiler error, whereas the static_cast approach:

    m->add(fun(static_cast<std::vector<string>(*)(string const&, string const&, bool)>(&ci::split)), "split");

compiles fine. On other compilers I've used, such as VS 2022, it builds fine (also with C++17 switches).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions