[libc-commits] [libc] [libc] fix get_epoch constexpr error (PR #126818)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Feb 11 14:52:34 PST 2025


https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/126818

get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.


>From bb4ac8df8cb4c87fa3d44d4783d034769227bcf4 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Tue, 11 Feb 2025 14:51:18 -0800
Subject: [PATCH] [libc] fix get_epoch constexpr error

get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.
---
 libc/src/time/time_utils.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h
index 30cdcbc170639..324e129f6f780 100644
--- a/libc/src/time/time_utils.h
+++ b/libc/src/time/time_utils.h
@@ -328,9 +328,7 @@ class TMReader final {
     return BASE_YEAR + IS_NEXT_YEAR;
   }
 
-  LIBC_INLINE constexpr time_t get_epoch() const {
-    return mktime_internal(timeptr);
-  }
+  LIBC_INLINE time_t get_epoch() const { return mktime_internal(timeptr); }
 
   // returns the timezone offset in microwave time:
   // return (hours * 100) + minutes;



More information about the libc-commits mailing list