-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc] Fix implict cast to time_t warning #126947
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On some systems time_t is 32 bit, causing build errors (with -Werror) in get_epoch which attempts to implicitly convert an int64_t to a time_t.
Member
|
@llvm/pr-subscribers-libc Author: Michael Jones (michaelrj-google) ChangesOn some systems time_t is 32 bit, causing build errors (with -Werror) Full diff: https://github.com/llvm/llvm-project/pull/126947.diff 1 Files Affected:
diff --git a/libc/src/time/time_utils.h b/libc/src/time/time_utils.h
index 324e129f6f780..68eaac8c04f11 100644
--- a/libc/src/time/time_utils.h
+++ b/libc/src/time/time_utils.h
@@ -328,7 +328,9 @@ class TMReader final {
return BASE_YEAR + IS_NEXT_YEAR;
}
- LIBC_INLINE time_t get_epoch() const { return mktime_internal(timeptr); }
+ LIBC_INLINE time_t get_epoch() const {
+ return static_cast<time_t>(mktime_internal(timeptr));
+ }
// returns the timezone offset in microwave time:
// return (hours * 100) + minutes;
|
nickdesaulniers
approved these changes
Feb 12, 2025
Member
|
|
Contributor
|
LGTM. I am trying a local build. |
Prabhuk
approved these changes
Feb 12, 2025
flovent
pushed a commit
to flovent/llvm-project
that referenced
this pull request
Feb 13, 2025
On some systems time_t is 32 bit, causing build errors (with -Werror)
in get_epoch which attempts to implicitly convert an int64_t to a
time_t.
Fixes:
error: implicit conversion loses integer precision: 'int64_t' (aka 'long
long') to 'time_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
332 | return mktime_internal(timeptr);
| ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
joaosaffran
pushed a commit
to joaosaffran/llvm-project
that referenced
this pull request
Feb 14, 2025
On some systems time_t is 32 bit, causing build errors (with -Werror)
in get_epoch which attempts to implicitly convert an int64_t to a
time_t.
Fixes:
error: implicit conversion loses integer precision: 'int64_t' (aka 'long
long') to 'time_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
332 | return mktime_internal(timeptr);
| ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
sivan-shani
pushed a commit
to sivan-shani/llvm-project
that referenced
this pull request
Feb 24, 2025
On some systems time_t is 32 bit, causing build errors (with -Werror)
in get_epoch which attempts to implicitly convert an int64_t to a
time_t.
Fixes:
error: implicit conversion loses integer precision: 'int64_t' (aka 'long
long') to 'time_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
332 | return mktime_internal(timeptr);
| ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On some systems time_t is 32 bit, causing build errors (with -Werror)
in get_epoch which attempts to implicitly convert an int64_t to a
time_t.
Fixes: