Giter Site home page Giter Site logo

stephantlavavej / stl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/stl

12.0 12.0 0.0 28.59 MB

MSVC's implementation of the C++ Standard Library.

License: Other

CMake 0.21% C++ 99.27% PowerShell 0.07% Perl 0.05% Python 0.39% Shell 0.01%

stl's People

Contributors

achabense avatar adambucior avatar alexguteniev avatar arzaghi avatar ataridreams avatar barcharcraz avatar bhardwajs avatar billyoneal avatar caseycarter avatar cbezault avatar cpplearner avatar frederick-vs-ja avatar fsb4000 avatar futuarmo avatar grcm10 avatar jeanphilippekernel avatar jmazurkiewicz avatar joemmett avatar mattstephanson avatar michaelrizkalla avatar miscco avatar nathansward avatar neargye avatar sam20908 avatar statementreply avatar stephantlavavej avatar strega-nil-ms avatar superwig avatar svido avatar sylveon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stl's Issues

`<variant>`: Error with non-trivial types

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: e7b0197

  • This bug is:
    rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\cpp\STL\cpp-meo>type bug-3.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <variant>
#else
import std;
#endif

struct A
{
  ~A() { };
  //~A() = default; // works
};

int main()
{
    [[maybe_unused]] std::variant<A> v;
}
D:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-3.cpp ..\std.obj /DUSE_CLASSIC_INCLUDES && bug-3.exe
bug-3.cpp

D:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-3.cpp ..\std.obj && bug-3.exe
bug-3.cpp
D:\cpp\STL\out\x64\out\inc\variant(844): error C3861: '_Destroy_in_place': identificador não encontrado
D:\cpp\STL\out\x64\out\inc\variant(590): note: consulte a referência à instanciação 'auto std::_Variant_base<A>::_Destroy::<lambda_1>::operator ()<std::_Tagged<_First &,0>>(_T1) noexcept const' do modelo que está sendo compilada
        with
        [
            _First=A,
            _T1=std::_Tagged<A &,0>
        ]
D:\cpp\STL\out\x64\out\inc\variant(708): note: consulte a referência à instanciação 'std::_Variant_raw_visit_t<std::_Variant_base<A>::_Destroy::<lambda_1>,std::_Variant_storage_<false,A>&>' do modelo da alias que está sendo compilada
D:\cpp\STL\out\x64\out\inc\variant(708): note: consulte a referência à instanciação 'unknown-type std::_Variant_raw_visit(unsigned __int64,_Storage &&,_Fn &&) noexcept(<expr>)' do modelo que está sendo compilada
D:\cpp\STL\out\x64\out\inc\variant(840): note: ao compilar a função de membro 'void std::_Variant_base<A>::_Destroy(void) noexcept' do modelo da classe
D:\cpp\STL\out\x64\out\inc\variant(897): note: consulte a referência à instanciação 'void std::_Variant_base<A>::_Destroy(void) noexcept' do modelo que está sendo compilada
D:\cpp\STL\out\x64\out\inc\variant(893): note: consulte a referência à instanciação 'std::_Variant_base<A>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\xsmf_control.h(24): note: consulte a referência à instanciação 'std::_Variant_destroy_layer_<A>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\xsmf_control.h(44): note: consulte a referência à instanciação 'std::_Non_trivial_copy<std::_Variant_destroy_layer_<A>>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\xsmf_control.h(65): note: consulte a referência à instanciação 'std::_Non_trivial_move<std::_Variant_destroy_layer_<A>,A>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\xsmf_control.h(103): note: consulte a referência à instanciação 'std::_Non_trivial_copy_assign<std::_Variant_destroy_layer_<A>,A>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\variant(983): note: consulte a referência à instanciação 'std::_Non_trivial_move_assign<std::_Variant_destroy_layer_<A>,A>' do modelo da classe que está sendo compilada
bug-3.cpp(16): note: consulte a referência à instanciação 'std::variant<A>' do modelo da classe que está sendo compilada
D:\cpp\STL\out\x64\out\inc\variant(842): error C2672: '_Variant_raw_visit': nenhuma função sobrecarregada correspondente encontrada
D:\cpp\STL\out\x64\out\inc\variant(708): note: poderia ser 'unknown-type std::_Variant_raw_visit(unsigned __int64,_Storage &&,_Fn &&) noexcept(<expr>)'

Additional Context

With types that don't trigger the non_trivial machinery it works. First identified the problem with std::string.

`<ctime>`: `time()`/`localtime()`/`mktime()` emit error C2129: static function declared but not defined

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 83b0eb5

  • This bug is: rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\GitHub\STL>type purr.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <cstdio>
#include <ctime>
#else
import std;
#endif

#pragma warning(disable : 4996) // CRT deprecation of localtime()

int main() {
#ifdef USE_CLASSIC_INCLUDES
    std::puts("Classic includes.");
#else
    std::puts("Named modules.");
#endif

    const std::time_t now        = std::time(nullptr);
    std::tm local                = *std::localtime(&now);
    const std::time_t round_trip = std::mktime(&local);

    std::printf("                 now: %lld\n", static_cast<long long>(now));
    std::printf("local.tm_year + 1900: %d\n", local.tm_year + 1900);
    std::printf("          round_trip: %lld\n", static_cast<long long>(round_trip));

    std::puts("Done!");
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /DUSE_CLASSIC_INCLUDES purr.cpp && purr.exe
purr.cpp
Classic includes.
                 now: 1659072489
local.tm_year + 1900: 2022
          round_trip: 1659072489
Done!

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od purr.cpp std.obj && purr.exe
purr.cpp
purr.cpp(27): error C2129: static function 'tm *localtime(const __int64 *const )' declared but not defined
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\time.h(495): note: see declaration of 'localtime'

Additional Context

Found by building tests/tr1/tests/chrono, ctime, cwchar2, locale3, locale4 with modules.

Each of time(), localtime(), mktime() will emit this error if they're the only call in the TU.

`<format> + <chrono>`: Could not format time_points

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 6c96fe7

  • This bug is:
    rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

d:\cpp\STL\cpp-meo>type bug-2.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <chrono>
#include <format>
#include <iostream>
#else
import std;
#endif

int main()
{
    std::cout << std::format("{}\n", std::chrono::system_clock::time_point {});
}
d:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-2.cpp ..\std.obj /DUSE_CLASSIC_INCLUDES && bug-2.exe/DUSE_CLASSIC_INCLUDES && bug-1.exe
bug-2.cpp
1970-01-01 00:00:00.0000000

d:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-2.cpp ..\std.obj && bug-2.exe
bug-2.cpp
d:\cpp\STL\out\x64\out\inc\chrono(5827): error C3861: '_Choose_literal': identificador não encontrado
d:\cpp\STL\out\x64\out\inc\chrono(5828): note: Este diagnóstico ocorreu na função gerada pelo compilador 'std::formatter<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>,_CharT>::formatter(void)'
        with
        [
            _CharT=char
        ]
d:\cpp\STL\out\x64\out\inc\format(3176): note: confira a referência à função 'std::formatter<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>,_CharT>::formatter(void)'
        with
        [
            _CharT=char
        ]
d:\cpp\STL\out\x64\out\inc\format(3190): note: consulte a referência à instanciação 'std::_String_view_iterator<_Traits> std::_Compile_time_parse_format_specs<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>,std::basic_format_parse_context<_CharT>>(_ParseContext &)' do modelo que está sendo compilada
        with
        [
            _Traits=std::char_traits<char>,
            _CharT=char,
            _ParseContext=std::basic_format_parse_context<char>
        ]
d:\cpp\STL\out\x64\out\inc\format(3190): note: ao compilar a função de membro 'std::_Format_checker<_CharT,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>>::_Format_checker(std::basic_string_view<_CharT,std::char_traits<char>>) noexcept' do modelo da classe
        with
        [
            _CharT=char
        ]
d:\cpp\STL\out\x64\out\inc\format(3355): note: consulte a referência à instanciação 'std::_Format_checker<_CharT,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>>' do modelo da classe que está sendo compilada
        with
        [
            _CharT=char
        ]
bug-2.cpp(13): note: consulte a referência à instanciação 'std::_Basic_format_string<char,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<__int64,std::ratio<1,10000000>>>>::_Basic_format_string<char[4]>(const _Ty (&))' do modelo que está sendo compilada
        with
        [
            _Ty=char [4]
        ]

Additional Context

Based on #14, but a diferent error.

`<format> + <chrono>`: Could not format durations

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 6ddfaf5

  • This bug is:
    rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

d:\cpp\STL\cpp-meo>type bug-1.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <chrono>
#include <format>
#include <iostream>
#else
import std;
#endif

int main()
{
    std::cout << std::format("{}\n", std::chrono::seconds { 1 }); // or milliseconds, microseconds
}
d:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-1.cpp ..\std.obj /DUSE_CLASSIC_INCLUDES && bug-1.exe
bug-1.cpp
1s

d:\cpp\STL\cpp-meo>cl /EHsc /nologo /W4 /std:c++latest /reference ..\std.ifc /MTd /Od bug-1.cpp ..\std.obj && bug-1.exe
D:\cpp\STL\out\x64\out\inc\chrono(5732): error C3861: '_Fill_tm': identificador não encontrado
D:\cpp\STL\out\x64\out\inc\chrono(5732): note: '_Fill_tm': a função não foi declarada no contexto de definição de modelo e pode ser encontrada no contexto de instanciação somente via pesquisa dependente de argumento
D:\cpp\STL\out\x64\out\inc\format(538): note: consulte a referência à instanciação 'auto std::_Fill_tm_formatter<std::chrono::duration<__int64,std::ratio<1,1>>,_CharT>::format<_Context>(const _Ty &,_FormatContext &) const' do modelo que está sendo compilada
        with
        [
            _CharT=char,
            _Context=std::format_context,
            _Ty=std::chrono::duration<__int64,std::ratio<1,1>>,
            _FormatContext=std::format_context
        ]
D:\cpp\STL\out\x64\out\inc\format(1743): note: consulte a referência para o modelo de variável 'const bool _Has_formatter<std::chrono::duration<__int64,std::ratio<1,1> > &,std::basic_format_context<std::back_insert_iterator<std::_Fmt_buffer<char> >,char> >' sendo compilado
D:\cpp\STL\out\x64\out\inc\format(1792): note: consulte a referência à instanciação 'std::_Format_arg_traits<_Context>::_Storage_type<_Ty>' do modelo da alias que está sendo compilada
        with
        [
            _Context=std::format_context,
            _Ty=std::chrono::seconds &
        ]
D:\cpp\STL\out\x64\out\inc\format(1827): note: consulte a referência para o modelo de variável 'const size_t std::_Format_arg_traits<std::basic_format_context<std::back_insert_iterator<std::_Fmt_buffer<char> >,char> >::_Storage_size<std::chrono::duration<__int64,std::ratio<1,1> > &>' sendo compilado
D:\cpp\STL\out\x64\out\inc\format(3372): note: consulte a referência à instanciação 'std::_Format_arg_store<_Context,std::chrono::seconds &>' do modelo da classe que está sendo compilada
        with
        [
            _Context=std::format_context
        ]
D:\cpp\STL\out\x64\out\inc\format(3490): note: consulte a referência à instanciação 'auto std::make_format_args<std::format_context,std::chrono::seconds&>(std::chrono::seconds &)' do modelo que está sendo compilada
bug-1.cpp(13): note: consulte a referência à instanciação 'std::string std::format<std::chrono::seconds>(const std::_Basic_format_string<char,std::chrono::duration<__int64,std::ratio<1,1>>>,std::chrono::seconds &&)' do modelo que está sendo compilada

Additional Context

Sorry for the diagnostics, I instaled the compiler in Brazilian-Portuguese.

`<ranges>`: ICE with std::views::join_with

Basic Info

  • This bug is:
    ICE-on-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\bug-bash>type test.cpp
#ifdef USE_CLASSIC_INCLUDES
    #include <array>
    #include <ranges>
#else
    import std;
#endif

int main() {
    std::array<std::array<char, 10>, 10>{} | std::views::join_with(' ');
}
D:\bug-bash>cl /EHsc /nologo /W4 /std:c++latest /MTd /c /FoNUL /DUSE_CLASSIC_INCLUDES test.cpp
test.cpp

D:\bug-bash>cl /EHsc /nologo /W4 /std:c++latest /MTd /c /FoNUL test.cpp
test.cpp
D:\bug-bash\out\x64\out\inc\ranges(3883): fatal error C1001: Internal compiler error.
(compiler file 'msc1.cpp', line 1576)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'D:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.33.31627\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

Additional Context

None.

`<new>`: `get_new_handler()`/`set_new_handler()` emit error LNK2019: unresolved external symbol

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 83b0eb5

  • This bug is: rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\GitHub\STL>type purr.cpp
#include <assert.h>

#ifdef USE_CLASSIC_INCLUDES
#include <cstdio>
#include <new>
#else
import std;
#endif

int main() {
#ifdef USE_CLASSIC_INCLUDES
    std::puts("Classic includes.");
#else
    std::puts("Named modules.");
#endif

    const std::new_handler nh1 = std::get_new_handler();
    assert(nh1 == nullptr);

    const std::new_handler nh2 = std::set_new_handler(nullptr);
    assert(nh2 == nullptr);

    std::puts("Done!");
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /DUSE_CLASSIC_INCLUDES purr.cpp && purr.exe
purr.cpp
Classic includes.
Done!

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od purr.cpp std.obj && purr.exe
purr.cpp
purr.obj : error LNK2019: unresolved external symbol "void (__cdecl*__cdecl std::get_new_handler(void))(void)" (?get_new_handler@std@@YAP6AXXZXZ::<!std>) referenced in function main
purr.obj : error LNK2019: unresolved external symbol "void (__cdecl*__cdecl std::set_new_handler(void (__cdecl*)(void)))(void)" (?set_new_handler@std@@YAP6AXXZP6AXXZ@Z::<!std>) referenced in function main
purr.exe : fatal error LNK1120: 2 unresolved externals

Additional Context

Found by building tests/tr1/tests/new with modules.

`<exception>`: Restoring `uncaught_exception()` emits error C2059: syntax error: 'string'

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 46f25a4

  • This bug is: rejects-valid

Command-Line Test Case

My test case that works with classic includes in main 😻 but fails with classic includes 🙀 and named modules 😿 in bug-bash:

D:\GitHub\STL>type purr.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <cstdio>
#include <exception>
#else
import std;
#endif

void detect_eh(const char* const str) {
#pragma warning(push)
#pragma warning(disable : 4996) // deprecated warning
    const auto val = std::uncaught_exception() ? "true" : "false";
#pragma warning(pop)
    std::printf("In %s, uncaught_exception() is %s.\n", str, val);
}

struct Kitty {
    Kitty() {
        detect_eh("Kitty()");
    }

    ~Kitty() {
        detect_eh("~Kitty()");
    }
};

int main() {
#ifdef USE_CLASSIC_INCLUDES
    std::puts("Classic includes.");
#else
    std::puts("Named modules.");
#endif

    try {
        Kitty k;
        throw 1729;
    } catch (const int&) {
        std::puts("Done.");
    }
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /D_HAS_DEPRECATED_UNCAUGHT_EXCEPTION purr.cpp /DUSE_CLASSIC_INCLUDES && purr.exe
purr.cpp
D:\GitHub\STL\out\x64\out\inc\exception(24): error C2059: syntax error: 'string'
purr.cpp(11): error C2039: 'uncaught_exception': is not a member of 'std'
[...]

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /D_HAS_DEPRECATED_UNCAUGHT_EXCEPTION /c stl\modules\std.ixx stl\modules\std.compat.ixx
std.ixx
D:\GitHub\STL\out\x64\out\inc\exception(24): error C2059: syntax error: 'string'
D:\GitHub\STL\out\x64\out\inc\ostream(113): error C2039: 'uncaught_exception': is not a member of 'std'
[...]

Additional Context

Found while investigating #20, but a different root cause. In that bug, I had missed marking get_new_handler() / set_new_handler() as extern "C++". In this bug, I had marked uncaught_exception() but did so incorrectly.

`<memory>`: `make_shared<T[]>(n)` and `allocate_shared<T[]>(al, n)` emit error C2248: cannot access private member

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: ec6e573

  • This bug is: rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\GitHub\STL>type purr.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <cstdio>
#include <memory>
#else
import std;
#endif

int main() {
#ifdef USE_CLASSIC_INCLUDES
    std::puts("Classic includes.");
#else
    std::puts("Named modules.");
#endif

    // _Make_shared_unbounded_array
    (void) std::make_shared<int[]>(3);
    (void) std::make_shared<int[]>(3, 1729);
    (void) std::make_shared_for_overwrite<int[]>(3);

    // _Allocate_shared_unbounded_array
    std::allocator<int> al;
    (void) std::allocate_shared<int[]>(al, 3);
    (void) std::allocate_shared<int[]>(al, 3, 1729);
    (void) std::allocate_shared_for_overwrite<int[]>(al, 3);

    std::puts("Done!");
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /DUSE_CLASSIC_INCLUDES purr.cpp && purr.exe
purr.cpp
Classic includes.
Done!

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od purr.cpp std.obj && purr.exe
purr.cpp
D:\GitHub\STL\out\x64\out\inc\memory(2764): error C2248: 'std::shared_ptr<int []>::_Set_ptr_rep_and_enable_shared': cannot access private member declared in class 'std::shared_ptr<int []>'
D:\GitHub\STL\out\x64\out\inc\memory(1785): note: see declaration of 'std::shared_ptr<int []>::_Set_ptr_rep_and_enable_shared'
D:\GitHub\STL\out\x64\out\inc\memory(1493): note: see declaration of 'std::shared_ptr<int []>'
D:\GitHub\STL\out\x64\out\inc\memory(2779): note: see reference to function template instantiation 'std::shared_ptr<int []> std::_Make_shared_unbounded_array<_Ty,>(const size_t)' being compiled
        with
        [
            _Ty=int []
        ]
purr.cpp(16): note: see reference to function template instantiation 'std::shared_ptr<int []> std::make_shared<int[]>(const size_t)' being compiled
D:\GitHub\STL\out\x64\out\inc\memory(2870): error C2248: 'std::shared_ptr<int []>::_Set_ptr_rep_and_enable_shared': cannot access private member declared in class 'std::shared_ptr<int []>'
D:\GitHub\STL\out\x64\out\inc\memory(1785): note: see declaration of 'std::shared_ptr<int []>::_Set_ptr_rep_and_enable_shared'
D:\GitHub\STL\out\x64\out\inc\memory(1493): note: see declaration of 'std::shared_ptr<int []>'
D:\GitHub\STL\out\x64\out\inc\memory(2891): note: see reference to function template instantiation 'std::shared_ptr<int []> std::_Allocate_shared_unbounded_array<_Ty,_Alloc,>(const _Alloc &,const size_t)' being compiled
        with
        [
            _Ty=int [],
            _Alloc=std::allocator<int>
        ]
purr.cpp(22): note: see reference to function template instantiation 'std::shared_ptr<int []> std::allocate_shared<int[],std::allocator<int>>(const _Alloc &,const size_t)' being compiled
        with
        [
            _Alloc=std::allocator<int>
        ]

Additional Context

Found while investigating #22.

I believe this has the same root cause, active compiler bug VSO-1538698 "Better handling for non-exported friend function declarations", but the affected functions and error symptoms are totally different.

`<ranges>`: could not use std::views::istream

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 6ddfaf5

  • This bug is:
    rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

c:\STL\STL>type helloworld.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <ranges>
#include <iostream>
#include <algorithm>
#else
import std;
#endif // USE_CLASSIC_INCLUDES

namespace stdr = std::ranges;
namespace stdv = std::views;

int main()
{
    auto input = stdv::istream<int>(std::cin)
        | stdv::take_while([](auto e) { return e != 0; });
    stdr::for_each(input, [](auto e) { std::cout << e << '\n'; });
}
c:\STL\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od helloworld.cpp /DUSE_CLASSIC_INCLUDES && helloworld.exe
helloworld.cpp
1 2 3 0
1
2
3

c:\STL\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od helloworld.cpp std.obj
helloworld.cpp
helloworld.obj : error LNK2019: 无法解析的外部符号 "struct _Istream_fn<int>::std::ranges::_Istream_fn<int> const std::ranges::views::istream<int>" (??$istream@H@views@ranges@std@@3U?$_Istream_fn@H@123@B::<!std>),函数 _main 中引用了该符号
helloworld.exe : fatal error LNK1120: 1 个无法解析的外部命令

Additional Context

Do I get the format right?

`<unordered_map>`, `<unordered_set>`: Equality comparisons emit error C2668: `'std::_Hash_equal'`: ambiguous call to overloaded function

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 83b0eb5

  • This bug is: rejects-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\GitHub\STL>type purr.cpp
#include <assert.h>

#ifdef USE_CLASSIC_INCLUDES
#include <cstdio>
#include <unordered_set>
#else
import std;
#endif

int main() {
#ifdef USE_CLASSIC_INCLUDES
    std::puts("Classic includes.");
#else
    std::puts("Named modules.");
#endif

    std::unordered_set<int> a{11, 22, 33};
    std::unordered_set<int> b{33, 22, 11};
    std::unordered_set<int> c{40, 50, 60};

    assert(a == b);
    assert(a != c);

    std::puts("Done!");
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od /DUSE_CLASSIC_INCLUDES purr.cpp && purr.exe
purr.cpp
Classic includes.
Done!

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od purr.cpp std.obj && purr.exe
purr.cpp
D:\GitHub\STL\out\x64\out\inc\unordered_set(321): error C2668: 'std::_Hash_equal': ambiguous call to overloaded function
D:\GitHub\STL\out\x64\out\inc\xhash(1988): note: could be 'bool std::_Hash_equal<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>>(const std::_Hash<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>> &,const std::_Hash<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>> &)'
        with
        [
            _Kty=int,
            _Hasher=std::hash<int>,
            _Keyeq=std::equal_to<int>,
            _Alloc=std::allocator<int>
        ]
D:\GitHub\STL\out\x64\out\inc\xhash(363): note: or       'bool std::_Hash_equal<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>>(const std::_Hash<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>> &,const std::_Hash<std::_Uset_traits<_Kty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>> &)' [found using argument-dependent lookup]
        with
        [
            _Kty=int,
            _Hasher=std::hash<int>,
            _Keyeq=std::equal_to<int>,
            _Alloc=std::allocator<int>
        ]
D:\GitHub\STL\out\x64\out\inc\unordered_set(321): note: while trying to match the argument list '(const std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int>>, const std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int>>)'
purr.cpp(21): note: see reference to function template instantiation 'bool std::operator ==<int,std::hash<int>,std::equal_to<int>,std::allocator<int>>(const std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int>> &,const std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int>> &)' being compiled

Additional Context

Found by building tests/tr1/tests/unordered_map, unordered_set with modules.

This affects all of the unordered containers: unordered_map, unordered_multimap, unordered_set, unordered_multiset.

_Hash_equal is a friend:

STL/stl/inc/xhash

Lines 362 to 363 in 83b0eb5

template <class _TraitsT>
friend bool _Hash_equal(const _Hash<_TraitsT>& _Left, const _Hash<_TraitsT>& _Right);

Therefore I believe that this is an active compiler bug, internal VSO-1538698 "Better handling for non-exported friend function declarations". I should be able to add a library workaround.

`<ranges>`: Usage of `ranges::iterator_t` causes ICE

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.
  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.
  • My current commit, as printed by git rev-parse HEAD, is: 83b0eb5585b6726203fb867ecdd9bda298fd38c1
  • This bug is: ICE-on-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

PS D:\stl-playground\named_modules> type .\main.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <concepts>
#include <ranges>
#else
import std;
#endif

int main() {
    using U = std::ranges::iterator_t<int(&)[3]>;
    static_assert(std::same_as<U, int*>);
}
PS D:\stl-playground\named_modules> $STL = "D:\stl"                                      
>> $CXXFLAGS = "/EHsc", "/nologo", "/W4", "/std:c++latest", "/MTd", "/Od", "/Femain.exe",
>>             "/reference", "$STL\std.ifc", "$STL\std.obj",
>>             "/reference", "$STL\std.compat.ifc", "$STL\std.compat.obj"
PS D:\stl-playground\named_modules> cl $CXXFLAGS .\main.cpp /DUSE_CLASSIC_INCLUDES
main.cpp
PS D:\stl-playground\named_modules> .\main.exe                                           
PS D:\stl-playground\named_modules> cl $CXXFLAGS .\main.cpp
main.cpp
.\main.cpp(9): fatal error C1001: Internal compiler error.
(compiler file 'msc1.cpp', line 1576)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
D:\stl\out\x64\out\inc\xutility(1912): note: see reference to alias template instantiation 'std::ranges::iterator_t<_Rng>' being compiled
INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.33.31629\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

Additional Context

  • This error propagates to other types:
#ifdef USE_CLASSIC_INCLUDES
#include <iterator>
#include <set>
#else
import std;
#endif

int main() {
    std::set<int> x;
    auto z = std::inserter(x, x.end());
}
PS D:\stl-playground\named_modules> cl $CXXFLAGS .\main.cpp
main.cpp
.\main.cpp(10): fatal error C1001: Internal compiler error.
(compiler file 'msc1.cpp', line 1576)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
D:\stl\out\x64\out\inc\xutility(1912): note: see reference to alias template instantiation 'std::ranges::iterator_t<_Rng>' being compiled
INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.33.31629\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

`<variant>`: Constructor inheritance causes ICE when class in named module inherits from class imported from `module std`

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.
  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.
  • My current commit, as printed by git rev-parse HEAD, is: 6c96fe702ab23df846cca2110bc8dc08e2aa6d3a
  • This bug is: ICE-on-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

PS D:\stl-playground> type .\mod.ixx
module;
#ifdef USE_CLASSIC_INCLUDES
#include <variant>
#endif
export module part;

#ifndef USE_CLASSIC_INCLUDES
import std;
#endif

using Base = std::variant<double, int>;

export struct DoubleOrInt : public Base {
    using Base::Base;
};

Other source file:

PS D:\stl-playground> type .\main.cpp
import part;

int main() {
    [[maybe_unused]] DoubleOrInt it_is_ice_time;
}
PS D:\stl-playground> $CXXFLAGS = '/EHsc', '/nologo', '/W4', '/std:c++latest', '/MTd', '/Od'
PS D:\stl-playground> $STL = 'D:\stl'      
PS D:\stl-playground> # Correct compilation
PS D:\stl-playground> cl $CXXFLAGS /c mod.ixx /reference $STL\std.ifc /DUSE_CLASSIC_INCLUDES    
mod.ixx
PS D:\stl-playground> cl $CXXFLAGS main.cpp mod.obj /reference $STL\std.ifc $STL\std.obj    
main.cpp
PS D:\stl-playground> .\main.exe
PS D:\stl-playground> # Bad compilation
PS D:\stl-playground> cl $CXXFLAGS /c mod.ixx /reference $STL\std.ifc  
mod.ixx
PS D:\stl-playground> cl $CXXFLAGS main.cpp mod.obj /reference $STL\std.ifc $STL\std.obj    
main.cpp
main.cpp(4): fatal error C1001: Internal compiler error.
(compiler file 'msc1.cpp', line 1576)
 To work around this problem, try simplifying or changing the program near the locations listed above.
If possible please provide a repro here: https://developercommunity.visualstudio.com
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.33.31627\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

Additional Context

`<chrono>`: Spurious warning C4702: unreachable code

Basic Info

  • I have read the rules for the Standard Library Modules Bug Bash.

  • I have pulled and rebuilt the bug-bash branch in the last 24 hours.

  • My current commit, as printed by git rev-parse HEAD, is: 6c96fe7

  • This bug is: warning-on-valid

Command-Line Test Case

My test case that works with classic includes but fails with named modules:

D:\GitHub\STL>type repro.cpp
#ifdef USE_CLASSIC_INCLUDES
#include <chrono>
#include <format>
#include <iostream>
#else
import std;
#endif

int main() {
    std::cout << std::format("{}\n", std::chrono::seconds{1});
}
D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od repro.cpp /DUSE_CLASSIC_INCLUDES && repro.exe
repro.cpp
1s

D:\GitHub\STL>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od repro.cpp std.obj && repro.exe
repro.cpp
D:\GitHub\STL\out\x64\out\inc\chrono(5028) : warning C4702: unreachable code
D:\GitHub\STL\out\x64\out\inc\chrono(5603) : warning C4702: unreachable code
D:\GitHub\STL\out\x64\out\inc\chrono(5704) : warning C4702: unreachable code
D:\GitHub\STL\out\x64\out\inc\chrono(5471) : warning C4702: unreachable code
1s

The STL internally suppresses this warning, but Standard Library Modules isn't handling that suppression.

Additional Context

This test case is from @nico-engels in #14 ; after working around the compiler error reported there, I found this warning.

I've fully reduced this and reported it as internal VSO-1582381 "Standard Library Modules: Bogus warning C4702: unreachable code". Minimal repro:

C:\Temp>type library.ixx
export module library;

#pragma warning(push)
#pragma warning(disable : 4702)

namespace library {
    export template <typename T>
    int func(T t) {
        if constexpr (sizeof(T) == 1) {
            return t * 11;
        }
        return t * 111;
    }
} // namespace library

#pragma warning(pop)
C:\Temp>type meow.cpp
#include <stdio.h>

import library;

int main() {
    printf("%d\n", library::func(static_cast<unsigned char>(3)));
    printf("%d\n", library::func(4));
}
C:\Temp>cl /EHsc /nologo /W4 /std:c++latest /Femeow.exe library.ixx meow.cpp && meow
library.ixx
meow.cpp
Generating Code...
C:\Temp\library.ixx(12) : warning C4702: unreachable code
33
444

Without modules, suppression works:

C:\Temp>type classic.cpp
#include <stdio.h>

#pragma warning(push)
#pragma warning(disable : 4702)

namespace library {
    template <typename T>
    int func(T t) {
        if constexpr (sizeof(T) == 1) {
            return t * 11;
        }
        return t * 111;
    }
} // namespace library

#pragma warning(pop)

int main() {
    printf("%d\n", library::func(static_cast<unsigned char>(3)));
    printf("%d\n", library::func(4));
}
C:\Temp>cl /EHsc /nologo /W4 /std:c++latest classic.cpp && classic
classic.cpp
33
444

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.