<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/69678>69678</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang++ broken std::filesystem on windows
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          boludoz
      </td>
    </tr>
</table>

<pre>
    ```
#include <filesystem>
#include <iostream>
#include <string>
#include <windows.h>
#include <fstream>
#include <codecvt>

typedef unsigned int u32;

#ifdef _WIN32
static std::wstring CPToUTF16(u32 code_page, std::string_view input) {
    const auto size =
        MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);

    if (size == 0) {
        return {};
    }

    std::wstring output(size, L'\0');

    if (size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()),
                                    &output[0], static_cast<int>(output.size()))) {
        output.clear();
    }

    return output;
}

std::string UTF16ToUTF8(std::wstring_view input) {
    const auto size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()),
                                          nullptr, 0, nullptr, nullptr);
    if (size == 0) {
        return {};
    }

    std::string output(size, '\0');

    if (size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()),
                                    &output[0], static_cast<int>(output.size()), nullptr,
                                    nullptr)) {
        output.clear();
    }

    return output;
}

std::wstring UTF8ToUTF16W(std::string_view input) {
    return CPToUTF16(CP_UTF8, input);
}

#endif

int main() {
    // console UTF-8
    SetConsoleOutputCP(CP_UTF8);
    SetConsoleCP(CP_UTF8);

    // create file
    std::filesystem::path p{L"♻️.txt", std::filesystem::path::native_format}; // Explicit UTF-16 encoding
    std::filesystem::path evaluatep = {L"hello" / p};
    std::wstring evaluate = evaluatep.wstring();

    std::wcout << L"Bad wstring -> " << evaluate; // Explicit UTF-16 encoding

    std::cout << std::endl;

    std::cout << "String OK -> " << UTF16ToUTF8(evaluate) << std::endl; // Explicit UTF-8 codified
    
    std::cout << "Bad string -> " << evaluatep.string(); // Bad filesystem string() conversion

    std::cout << std::endl;

}
```
![image](https://github.com/llvm/llvm-project/assets/11653030/abad8498-fd5f-4cec-a78c-8bb85b659f78)
the programs stucks
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV1-P4jgM_zTmJQKVlP576MMWBul0e7cj7ZzmEaWNC7kNTdWkzM5--lPSAi0D80er27sKAY1d--ef7cRlWotthZhCkEGwmrDW7FST5kq2XP2Y5Io_pxB6_cdbgfcJqC-qQrYcCfjLUkjUz9rgHvy7awpCadMguyXWphHV9obwSVRcPenZ7oa8fNV0oTgWB3OWum_zXCPHkrSVi5wTURnS-hT8bKhmTZVWb_P4258-7Ra1YUYURBsO_ifwPz116Mny_kH99bCeh0Dj1qfEet7UbItAl2ftTnlzEPhERFW3BmhCIOrdEkJIoSptCGuNIlr8sEGszkJ7_dFKI7Jngw_qUXBc7lgDNB658-yXMz_jzDCgMdCkw2HBbwqmjU1L5Yihcadq3R1VnXbVSlmbpreYXLBjsYiSAI1POP2VUxwHZK8GTdtUbj1anexYib2_MPqCWtUax1TcIVySz0AjCJae_XkTF51bXL-MtXHgr11Awz6yIPMgWL3iqtO79JVc5brXLSS6EIcE3SC8z04P5sTmWPGihImrdVfysaX6ImcfrHByzMmDOiUKaLy833T2f31yumvcAaOOOP0d0_vvdsSthvh4P_zvCP_pbhhm5_1uB2n8L5rp6dxNcX9-PA7b6e1u6v0Nj59BFo_P3AIC1MeKi3K4Zg_DPRNVF-_YG9A10LVrYSXRwp7GZ-lXNMtO8sWFv7wfohlTd9a9pfXSa4PMILHjxpXeGE4h9r5mZkdqiLLPQCncUUgSyDK4W0MWQ7yeme_GCoan8zUT3b-KGXHATamaPTNdxx5R3X2vpSiEcWTMQ4JVobidZ94JEQ9Mtsxg7TbCHu8OpVRAqXVigxhvES_K52jDmTgZnPXii8K9Zq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