Repository navigation
[Support] Explicitly cast NANOSECONDS_PER_SECOND in TimeValue for C++26 - #9021
Open
Reginald Alfret V (reginaldalfret) wants to merge 4 commits into
Open
Reginald Alfret V (reginaldalfret) wants to merge 4 commits into
Reginald Alfret V (reginaldalfret) wants to merge 4 commits into
Conversation
Arithmetic between floating-point types and enumeration types was deprecated in C++20 and removed in C++26 by WG21 P2864R2. This caused Clang 22 with -std=c++26 to fail compiling include/llvm/Support/TimeValue.h. Explicitly cast NANOSECONDS_PER_SECOND to double to ensure compatibility with C++26 compilers. Fixes microsoft#8992 Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
| static_cast<double>(integer_part)) * NANOSECONDS_PER_SECOND ); | ||
| nanos_ = static_cast<NanoSecondsType>( | ||
| (new_time - static_cast<double>(integer_part)) * | ||
| static_cast<double>(NANOSECONDS_PER_SECOND)); |
There was a problem hiding this comment.
Added release note to docs/ReleaseNotes.md under ### Upcoming Release -> #### Bug Fixes.
Comment on lines
+110
to
+112
| nanos_ = static_cast<NanoSecondsType>( | ||
| (new_time - static_cast<double>(integer_part)) * | ||
| static_cast<double>(NANOSECONDS_PER_SECOND)); |
There was a problem hiding this comment.
Added a unit test in unittests/Support/TimeValueTest.cpp covering the sys::TimeValue(double) constructor. As noted in CONTRIBUTING.md:145-157 regarding changes for external projects and test infrastructure limitations, DXC's host build environment and test suite compile in C++14/C++17 across all CI runners and do not provide a Clang 22 / -std=c++26 toolchain to run compile-only C++26 tests directly in CI.
…microsoft#8992) Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This branch has not been deployed
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
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.

[Support] Explicitly cast NANOSECONDS_PER_SECOND in TimeValue for C++26
NANOSECONDS_PER_SECONDenum todoubleinllvm::sys::TimeValue(double)constructor-std=c++26Fixes #8992
Description
Arithmetic between floating-point types and enumeration types was deprecated in C++20 and removed in C++26 by WG21 P2864R2.
In
include/llvm/Support/TimeValue.h, line 111:Under Clang 22 with
-std=c++26, this produces:error: invalid arithmetic between floating-point type 'double' and enumeration type 'llvm::sys::TimeValue::TimeConversions'Explicitly casting
NANOSECONDS_PER_SECONDtodoubleresolves the compilation failure while preserving exact numerical semantics in all C++ standards.