-
Notifications
You must be signed in to change notification settings - Fork 187
Conversation
…tatic_cast in problematic areas
@@ -19,6 +19,11 @@ | |||
|
|||
#include "test_macros.h" | |||
|
|||
#if defined(_MSC_VER) | |||
# pragma warning( disable: 4307 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comments to these, similarly how the 4244 disables have comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments.
@@ -2534,7 +2534,7 @@ year_month_day::__from_days(days __d) noexcept | |||
const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365] | |||
const unsigned __mp = (5 * __doy + 2)/153; // [0, 11] | |||
const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31] | |||
const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12] | |||
const unsigned __mth = __mp + static_cast<unsigned>(__mp < 10 ? 3 : -9); // [1, 12] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-align the trailing comment with the 9nes in the previous lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realigned.
const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365] | ||
const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096] | ||
const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399] | ||
const unsigned __doy = static_cast<unsigned>((153 * (__mth + static_cast<unsigned>(__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1); // [0, 365] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the outer static_cast needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two problems mainly. __mth + negative signed integer
is a warning. The assignment ends up being a demotion as well after xy / 5 + __dy-1
This commit chain will include fixes to address failures detected across several versions of MSVC. I've used the compilers listed below that I believe are major releases for MSVC.
MSVC versions that are clean: