`chrono::abs` incorrectly uses `?:` with expressions that don't always have a common type (#2988)

This commit is contained in:
Casey Carter 2022-08-05 16:46:11 -07:00 коммит произвёл GitHub
Родитель 577269c56a
Коммит 1fe625d713
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -502,8 +502,12 @@ namespace chrono {
template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0>
_NODISCARD constexpr duration<_Rep, _Period> abs(const duration<_Rep, _Period> _Dur) noexcept(
is_arithmetic_v<_Rep>) /* strengthened */ {
// create a duration with count() the absolute value of _Dur.count()
return _Dur < duration<_Rep, _Period>::zero() ? duration<_Rep, _Period>::zero() - _Dur : _Dur;
// create a duration whose count() is the absolute value of _Dur.count()
if (_Dur < duration<_Rep, _Period>::zero()) {
return duration<_Rep, _Period>::zero() - _Dur;
} else {
return _Dur;
}
}
using nanoseconds = duration<long long, nano>;

Просмотреть файл

@ -794,9 +794,6 @@ std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.
std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp FAIL
std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp FAIL
# Likely STL bug in <chrono>: "result type of conditional expression is ambiguous"
std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp FAIL
# Likely STL bug in <format>: we check argument ids at compiletime in next_arg_id
std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp FAIL

Просмотреть файл

@ -790,9 +790,6 @@ localization\locale.categories\category.ctype\locale.codecvt\locale.codecvt.memb
localization\locale.categories\category.ctype\locale.codecvt\locale.codecvt.members\char32_t_encoding.pass.cpp
localization\locale.categories\category.ctype\locale.codecvt\locale.codecvt.members\char32_t_max_length.pass.cpp
# Likely STL bug in <chrono>: "result type of conditional expression is ambiguous"
utilities\time\time.duration\time.duration.alg\abs.pass.cpp
# Likely STL bug in <format>: we check argument ids at compiletime in next_arg_id
utilities\format\format.formatter\format.parse.ctx\next_arg_id.pass.cpp