Skip to content

Commit f2b931b

Browse files
committed
Do not use static member functions to initialize static member variables.
This is technically invalid, as the class is not yet complete during initialization of static member variables. Fixes nvbug4197970
1 parent a11c1c1 commit f2b931b

File tree

1 file changed

+10
-11
lines changed
  • libcudacxx/include/cuda/std/detail/libcxx/include

1 file changed

+10
-11
lines changed

libcudacxx/include/cuda/std/detail/libcxx/include/chrono

+10-11
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,14 @@ inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(co
31013101
_LIBCUDACXX_INLINE_VISIBILITY
31023102
inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
31033103

3104+
_LIBCUDACXX_NODISCARD_ATTRIBUTE inline _LIBCUDACXX_INLINE_VISIBILITY
3105+
constexpr unsigned __hh_mm_ss_width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
3106+
{
3107+
if (__n >= 2 && __d != 0 && __w < 19)
3108+
return 1 + __hh_mm_ss_width(__n, __d % __n * 10, __w+1);
3109+
return 0;
3110+
}
3111+
31043112
template <class _Duration>
31053113
class hh_mm_ss
31063114
{
@@ -3116,18 +3124,9 @@ private:
31163124
__ret *= 10U;
31173125
return __ret;
31183126
}
3119-
3120-
_LIBCUDACXX_INLINE_VISIBILITY
3121-
static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0)
3122-
{
3123-
if (__n >= 2 && __d != 0 && __w < 19)
3124-
return 1 + __width(__n, __d % __n * 10, __w+1);
3125-
return 0;
3126-
}
3127-
31283127
public:
3129-
static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ?
3130-
__width(__CommonType::period::den) : 6u;
3128+
static unsigned constexpr fractional_width = __hh_mm_ss_width(__CommonType::period::den) < 19 ?
3129+
__hh_mm_ss_width(__CommonType::period::den) : 6u;
31313130
using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>;
31323131

31333132
_LIBCUDACXX_INLINE_VISIBILITY

0 commit comments

Comments
 (0)