Skip to content

C++23 #include <format> from libstdc++ fails with "variable template ... cannot appear in its own initializer" #139466

@stbergmann

Description

@stbergmann

Apparently since 91f1830 "[Clang][Sema] Handle invalid variable template specialization whose type depends on itself (#134522)": At least when building agaisnt libstdc++-devel-15.1.1-1.fc42.x86_64,

$ cat test.cc
#include <format>
$ clang++ -std=c++23 -fsyntax-only test.cc
In file included from test.cc:1:
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/format:5165:7: error: variable template 'format_kind' declared with deduced type 'const auto' cannot appear in its own initializer
 5165 |       format_kind<_Rg> // you can specialize this for non-const input ranges
      |       ^
1 error generated.

(where therelevant contents of /usr/include/c++/15/format` is

  template<typename _Rg>
    constexpr auto format_kind =
    __primary_template_not_defined(
      format_kind<_Rg> // you can specialize this for non-const input ranges
    );

).

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicatelibstdc++GNU libstdc++ C++ standard library

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions