Skip to content

[libc++] Instantiation of pair in class template argument deduction is a bit too eager #133056

Closed
@frederick-vs-ja

Description

@frederick-vs-ja

The following code snippet is rejected with libc++ (Godbolt link):

#include <utility>
#include <type_traits>

// note that *+[]{} dereferences a function pointer converted from the lambda expression
static_assert(std::is_same_v<decltype(std::pair{0, *+[]{}}), std::pair<int, void(*)()>>);

It seems that the related implicit deduction guide synthesized from the constructor (pair(const T1&, const T2&) -> pair<T1, T2>) should be excluded by SFINAE mechanisms before instantiating invalid pair<int, void()>, and the decaying explicit deduction guide (pair(T1, T2) -> pair<T1, T2>) should work.

But libc++ currently makes the instantiation a bit too eager, and then causes hard error. I've roughly verified that this can (and perhaps should) be fixed within the library implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++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