Skip to content

Incompatibility of fmt/ranges.h and std::filesystem::path on Windows #3322

Description

@phprus

Code (https://godbolt.org/z/qYPafnW9a):

#include <iostream>
#include <filesystem>
#include <variant>
#include <fmt/std.h>
#include <fmt/ranges.h>

int main(int argc, char* argv[]) {
    auto v = std::variant<std::filesystem::path, int>("path/file.txt");
    std::cout << fmt::format("{}", v) << std::endl;
    return 0;
}

Errror:

example.cpp
C:\data\libraries\installed\x64-windows\include\fmt\core.h(1855): error C2968: 'is_formattable<std::filesystem::path,char>': recursive alias declaration
C:\data\libraries\installed\x64-windows\include\fmt\core.h(320): note: see reference to class template instantiation 'fmt::v9::detail::is_formattable_delayed<std::filesystem::path,char>' being compiled
C:\data\libraries\installed\x64-windows\include\fmt\core.h(323): note: see reference to class template instantiation 'fmt::v9::conjunction<fmt::v9::detail::is_formattable_delayed<std::filesystem::path,char>>' being compiled
C:/data/msvc/14.29.30145/include\type_traits(593): note: see reference to class template instantiation 'fmt::v9::conjunction<std::integral_constant<bool,true>,fmt::v9::detail::is_formattable_delayed<std::filesystem::path,char>>' being compiled
C:/data/libraries/installed/x64-windows/include\fmt/std.h(114): note: see reference to class template instantiation 'std::is_constructible<fmt::v9::formatter<std::filesystem::path,char,void>>' being compiled
C:/data/libraries/installed/x64-windows/include\fmt/std.h(114): note: see reference to alias template instantiation 'fmt::v9::is_formattable<std::filesystem::path,char>' being compiled
C:/data/libraries/installed/x64-windows/include\fmt/std.h(140): note: see reference to class template instantiation 'fmt::v9::detail::is_variant_formattable_<T,C>' being compiled
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/msvc/14.29.30145/include\type_traits(593): note: see reference to class template instantiation 'fmt::v9::is_variant_formattable<std::variant<std::filesystem::path,int>,char>' being compiled
C:/data/libraries/installed/x64-windows/include\fmt/ranges.h(418): note: see reference to variable template 'const bool conjunction_v<fmt::v9::is_variant_like<std::variant<std::filesystem::path,int> >,fmt::v9::is_variant_formattable<std::variant<std::filesystem::path,int>,char> >' being compiled
C:\data\libraries\installed\x64-windows\include\fmt\core.h(1530): note: see reference to class template instantiation 'std::is_constructible<fmt::v9::formatter<std::variant<std::filesystem::path,int>,char,void>>' being compiled
C:\data\libraries\installed\x64-windows\include\fmt\core.h(1729): note: see reference to alias template instantiation 'fmt::v9::detail::mapped_type_constant<std::variant<std::filesystem::path,int>,Context>' being compiled
        with
        [
            Context=fmt::v9::format_context
        ]
C:\data\libraries\installed\x64-windows\include\fmt\core.h(1890): note: see reference to function template instantiation 'unsigned __int64 fmt::v9::detail::encode_types<Context,std::variant<std::filesystem::path,int>,>(void)' being compiled
        with
        [
            Context=fmt::v9::format_context
        ]
C:\data\libraries\installed\x64-windows\include\fmt\core.h(3205): note: see reference to class template instantiation 'fmt::v9::format_arg_store<fmt::v9::format_context,std::variant<std::filesystem::path,int>>' being compiled
<source>(9): note: see reference to function template instantiation 'std::string fmt::v9::format<std::variant<std::filesystem::path,int>&>(fmt::v9::basic_format_string<char,std::variant<std::filesystem::path,int> &>,std::variant<std::filesystem::path,int> &)' being compiled
C:/data/libraries/installed/x64-windows/include\fmt/ranges.h(418): error C2955: 'fmt::v9::disjunction': use of class template requires template argument list
C:\data\libraries\installed\x64-windows\include\fmt\core.h(313): note: see declaration of 'fmt::v9::disjunction'
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): error C2672: 'fmt::v9::detail::is_variant_formattable_<T,C>::check': no matching overloaded function found
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): error C2893: Failed to specialize function template 'std::conjunction<std::integral_constant<bool,!std::is_base_of<fmt::v9::detail::unformattable,unknown-type>::value&&true>...> fmt::v9::detail::is_variant_formattable_<T,C>::check(std::integer_sequence<size_t,I...>)'
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/libraries/installed/x64-windows/include\fmt/std.h(115): note: see declaration of 'fmt::v9::detail::is_variant_formattable_<T,C>::check'
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): note: With the following template arguments:
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): note: 'I={0, 1}'
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): error C2651: 'unknown-type': left of '::' must be a class, struct or union
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): error C2062: type 'unknown-type' unexpected
C:/data/libraries/installed/x64-windows/include\fmt/std.h(118): error C2789: 'fmt::v9::detail::is_variant_formattable_<T,C>::value': an object of const-qualified type must be initialized
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/libraries/installed/x64-windows/include\fmt/std.h(118): note: see declaration of 'fmt::v9::detail::is_variant_formattable_<T,C>::value'
        with
        [
            T=std::variant<std::filesystem::path,int>,
            C=char
        ]
C:/data/libraries/installed/x64-windows/include\fmt/std.h(119): error C2039: 'value': is not a member of '`global namespace''
C:/data/libraries/installed/x64-windows/include\fmt/std.h(140): error C2131: expression did not evaluate to a constant
C:/data/libraries/installed/x64-windows/include\fmt/std.h(140): note: failure was caused by a read of an uninitialized symbol
C:/data/libraries/installed/x64-windows/include\fmt/std.h(140): note: see usage of 'value'
C:/data/msvc/14.29.30145/include\type_traits(593): fatal error C1903: unable to recover from previous error(s); stopping compilation
INTERNAL COMPILER ERROR in 'C:\data\msvc\14.29.30145\bin\Hostx64\x64\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
Compiler returned: 3221225477

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions