-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ambiguous duration units and add format check (#12225)
- ambiguous value-based std::chrono::{clock_type}::duration(value) constructors result in stdlib implementation specific default time units which are hard to read and potentially different on different platforms - this change removes any instances of these ambiguous constructions and adds a format check to prevent them; developers should specify an explicit unit of time - we explicitly saw this issue in #11915 where the assumed duration unit was different on Windows, causing test failures Additional Description: Risk Level: Low Testing: Adds format check test and adjust existing unit tests Docs Changes: N/A Release Notes: N/A Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com> Co-authored-by: William A Rowe Jr <wrowe@vmware.com>
- Loading branch information
1 parent
e8aab1b
commit 0b1cf9d
Showing
7 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <chrono> | ||
|
||
namespace Envoy { | ||
|
||
std::chrono::duration<long int, std::nano> foo() { | ||
return std::chrono::steady_clock::duration(12345); | ||
} | ||
|
||
} // namespace Envoy |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <chrono> | ||
|
||
namespace Envoy { | ||
|
||
std::chrono::duration<long int, std::nano> foo_int() { | ||
return std::chrono::steady_clock::duration(0); | ||
} | ||
|
||
std::chrono::duration<long int, std::nano> foo_decimal() { | ||
return std::chrono::steady_clock::duration(0.0); | ||
} | ||
|
||
} // namespace Envoy |