[gcc r16-4299] libstdc++: Fix type in computation of _M_weekday_index.
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Wed Oct 8 13:41:53 GMT 2025
https://gcc.gnu.org/g:43f524c1c4f1aa79e3c443b45af9464a8b8943b1
commit r16-4299-g43f524c1c4f1aa79e3c443b45af9464a8b8943b1
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Wed Oct 8 15:14:04 2025 +0200
libstdc++: Fix type in computation of _M_weekday_index.
The value should use divide instead of modulo, as given 1st of month
being weekday X (Mon, Tue, ...), 01 is always X[1], 08 is X[2], e.t.c.
This values is currently not observable, as there is no user-accessible
format specifier that will print it, however it may be exposed in future.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h (_ChronoData::_M_fill_day): Replace
'%' by '/'.
Diff:
---
libstdc++-v3/include/bits/chrono_io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/chrono_io.h b/libstdc++-v3/include/bits/chrono_io.h
index 79a44d128b12..690c10d79ce5 100644
--- a/libstdc++-v3/include/bits/chrono_io.h
+++ b/libstdc++-v3/include/bits/chrono_io.h
@@ -463,7 +463,7 @@ namespace __format
{
_M_day = __d;
__parts -= _ChronoParts::_Day;
- _M_weekday_index = ((unsigned)__d + 6u) % 7u;
+ _M_weekday_index = ((unsigned)__d + 6u) / 7u;
__parts -= _ChronoParts::_WeekdayIndex;
return __parts;
}
More information about the Libstdc++-cvs
mailing list