Skip to content

Template with make_shared started failing with c++20 and libc++ #78614

Closed as not planned
@brendandahl

Description

@brendandahl

This was previously compiling with c++17. It also works with libstdc++/c++20 and msvc/c++20.

#include <memory>

class Foo {
public:
    Foo(int i) {}
};

template<typename Callable>
void constructor(Callable callable) {}

int main() {
    // std::shared_ptr<Foo> (*)(int &&)
    constructor(&std::make_shared<Foo, int>);
}

Flags: -stdlib=libc++ -std=c++20 main.cpp

Error:

main.cpp:15:5: error: no matching function for call to 'constructor'
   15 |     constructor(&std::make_shared<Foo, int>);
      |     ^~~~~~~~~~~
main.cpp:9:6: note: candidate template ignored: couldn't infer template argument 'Callable'
    9 | void constructor(Callable callable) {
      |      ^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidResolved as invalid, i.e. not a buglibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions