D:\GitHub\STL\out\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od meow.cpp
meow.cpp
D:\GitHub\STL\out\x64\out\inc\chrono(1604): error C2672: 'std::chrono::abs': no matching overloaded function found
D:\GitHub\STL\out\x64\out\inc\__msvc_chrono.hpp(499): note: could be 'std::chrono::duration<_Rep,_Period> std::chrono::abs(const std::chrono::duration<_Rep,_Period>) noexcept(<expr>)'
D:\GitHub\STL\out\x64\out\inc\chrono(1604): note: 'std::chrono::duration<_Rep,_Period> std::chrono::abs(const std::chrono::duration<_Rep,_Period>) noexcept(<expr>)': could not deduce template argument for '__formal'
D:\GitHub\STL\out\x64\out\inc\__msvc_chrono.hpp(498): note: 'std::enable_if_t<false,int>' : Failed to specialize alias template
D:\GitHub\STL\out\x64\out\inc\chrono(1604): note: the template instantiation context (the oldest one first) is
meow.cpp(10): note: see reference to function template instantiation 'std::basic_format_string<char,const std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>> &>::basic_format_string<char[22]>(const _Ty (&))' being compiled
with
[
_Ty=char [22]
]
D:\GitHub\STL\out\x64\out\inc\format(3802): note: see reference to class template instantiation 'std::__p2286::_Format_checker<_CharT,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>>' being compiled
with
[
_CharT=char
]
D:\GitHub\STL\out\x64\out\inc\format(3579): note: while compiling class template member function 'std::__p2286::_Format_checker<_CharT,std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>>::_Format_checker(std::basic_string_view<char,std::char_traits<char>>) noexcept'
with
[
_CharT=char
]
D:\GitHub\STL\out\x64\out\inc\format(3580): note: see reference to function template instantiation 'std::_String_view_iterator<_Traits> std::__p2286::_Compile_time_parse_format_specs<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>,std::basic_format_parse_context<char>>(_ParseContext &)' being compiled
with
[
_Traits=std::char_traits<char>,
_ParseContext=std::basic_format_parse_context<char>
]
D:\GitHub\STL\out\x64\out\inc\format(3559): note: see reference to alias template instantiation 'std::_Format_arg_traits<_Context>::_Storage_type<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>>' being compiled
with
[
_Context=std::format_context
]
D:\GitHub\STL\out\x64\out\inc\format(847): note: see reference to variable template 'bool _Formattable_with<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1> > >,std::basic_format_context<std::back_insert_iterator<std::_Fmt_buffer<char> >,char>,std::formatter<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1> > >,char> >' being compiled
D:\GitHub\STL\out\x64\out\inc\format(662): note: see reference to function template instantiation '_OutputIt std::formatter<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>,_CharT>::format<_Context>(const std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>> &,_FormatContext &) const' being compiled
with
[
_OutputIt=std::back_insert_iterator<std::_Fmt_buffer<char>>,
_CharT=char,
_Context=std::format_context,
_FormatContext=std::format_context
]
D:\GitHub\STL\out\x64\out\inc\chrono(5879): note: see reference to function template instantiation 'tm std::chrono::_Fill_tm<std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>>(const _Ty &)' being compiled
with
[
_Ty=std::chrono::time_point<std::chrono::system_clock,std::chrono::duration<unsigned int,std::ratio<1,1>>>
]
D:\GitHub\STL\out\x64\out\inc\chrono(4994): note: see reference to class template instantiation 'std::chrono::hh_mm_ss<std::chrono::duration<unsigned int,std::ratio<1,1>>>' being compiled
D:\GitHub\STL\out\x64\out\inc\chrono(1602): note: while compiling class template member function 'std::chrono::hh_mm_ss<std::chrono::duration<unsigned int,std::ratio<1,1>>>::hh_mm_ss(_Duration)'
with
[
_Duration=std::chrono::duration<unsigned int,std::ratio<1,1>>
]
D:\GitHub\STL\out\x64\out\inc\chrono(5063): note: see the first reference to 'std::chrono::hh_mm_ss<std::chrono::duration<unsigned int,std::ratio<1,1>>>::hh_mm_ss' in 'std::chrono::_Fill_tm'
[...]
MSVC error:
Clang error:
WG21-N4964 [time.duration.alg]/1 says for
chrono::abs(duration<Rep, Period>):[time.hms.members]/3 says that
chrono::hh_mm_ss(Duration d)usesabs(d).We use
chrono::hh_mm_ssto implement chrono formatting:STL/stl/inc/chrono
Line 5063 in f392449
But I see nothing in [time.format] that allows us to reject unsigned durations in chrono formatting.
Originally reported as DevCom-10501153 / VSO-1910245 / AB#1910245 .
As mentioned in the original bug report, GCC/libstdc++ and Clang/libc++ accept this code: https://godbolt.org/z/n9EGxzY46