Skip to content

[C++][concepts] error implicit instantiation of undefined template reported from checking constraint satisfaction #131136

Open
@thbwd

Description

@thbwd
#include <string>

template <template <typename> class SB>
concept Trait = requires(SB<int> a) { a.holder0; };

template <typename T> void set_property(T);

template <template <typename> class SB, typename ST>
void set_property(SB<ST> *) requires Trait<SB>;

void initialize(std::string *name) { set_property(name); }

Produces the following output:

% /opt/homebrew/Cellar/llvm/19.1.7_1/bin/clang test.cpp -std=c++20
In file included from test.cpp:1:
/opt/homebrew/Cellar/llvm/19.1.7_1/bin/../include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<int>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
test.cpp:4:40: note: in instantiation of template class 'std::basic_string<int>' requested here
    4 | concept Trait = requires(SB<int> a) { a.holder0; };
      |                                        ^
test.cpp:4:39: note: in instantiation of requirement here
    4 | concept Trait = requires(SB<int> a) { a.holder0; };
      |                                       ^~~~~~~~~
test.cpp:4:17: note: while substituting template arguments into constraint expression here
    4 | concept Trait = requires(SB<int> a) { a.holder0; };
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cpp:9:38: note: while checking the satisfaction of concept 'Trait<std::basic_string>' requested here
    9 | void set_property(SB<ST> *) requires Trait<SB>;
      |                                      ^~~~~~~~~
test.cpp:9:38: note: while substituting template arguments into constraint expression here
    9 | void set_property(SB<ST> *) requires Trait<SB>;
      |                                      ^~~~~~~~~
test.cpp:11:38: note: while checking constraint satisfaction for template 'set_property<std::basic_string, char>' required here
   11 | void initialize(std::string *name) { set_property(name); }
      |                                      ^~~~~~~~~~~~
test.cpp:11:38: note: in instantiation of function template specialization 'set_property<std::basic_string, char>' requested here
/opt/homebrew/Cellar/llvm/19.1.7_1/bin/../include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
1 error generated.

This compiles fine with 18.1.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 concepts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions