Skip to content

[libc] fix get_epoch constexpr error #126818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

michaelrj-google
Copy link
Contributor

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

get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/126818.diff

1 Files Affected:

  • (modified) libc/src/time/time_utils.h (+1-3)
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;

@lntue
Copy link
Contributor

lntue commented Feb 11, 2025

Is there anything preventing mktime_internal to be constexpr?

@michaelrj-google
Copy link
Contributor Author

Is there anything preventing mktime_internal to be constexpr?

I'd need to move it to be in the header. We can do that in future, but for now I'm going to land this to fix the buildbots

@michaelrj-google michaelrj-google merged commit 574ccc6 into llvm:main Feb 12, 2025
13 of 14 checks passed
@michaelrj-google michaelrj-google deleted the libcNonConstexprEpoch branch February 12, 2025 00:08
@nickdesaulniers
Copy link
Member

Fixes: #126138

flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
get_epoch calls mktime_internal which isn't constexpr. For now, just
remove the constexpr from get_epoch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants