summaryrefslogtreecommitdiff
path: root/absl/time/duration.cc
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2022-06-14 18:04:19 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-06-14 18:04:54 -0700
commit2e36d96669b0f56eaf865245c7bcf8060963a088 (patch)
tree99f736e54839e356ee31705769dcd79fc5aa36ec /absl/time/duration.cc
parentae228edc168d9300bb49f72b1388166691fbf20a (diff)
absl::Time: work around bogus GCC 12 -Wrestrict warning
Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336 PiperOrigin-RevId: 455001261 Change-Id: If0c72766a2a1d1e87c19c93c07cf62917031415b
Diffstat (limited to 'absl/time/duration.cc')
-rw-r--r--absl/time/duration.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/absl/time/duration.cc b/absl/time/duration.cc
index 4443109a..2bba62da 100644
--- a/absl/time/duration.cc
+++ b/absl/time/duration.cc
@@ -766,13 +766,14 @@ void AppendNumberUnit(std::string* out, double n, DisplayUnit unit) {
// is non-zero.
// Unlike Go, we format the zero duration as 0, with no unit.
std::string FormatDuration(Duration d) {
- const Duration min_duration = Seconds(kint64min);
- if (d == min_duration) {
+ constexpr Duration kMinDuration = Seconds(kint64min);
+ std::string s;
+ if (d == kMinDuration) {
// Avoid needing to negate kint64min by directly returning what the
// following code should produce in that case.
- return "-2562047788015215h30m8s";
+ s = "-2562047788015215h30m8s";
+ return s;
}
- std::string s;
if (d < ZeroDuration()) {
s.append("-");
d = -d;