diff options
author | Derek Mauro <dmauro@google.com> | 2022-06-14 18:04:19 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-06-14 18:04:54 -0700 |
commit | 2e36d96669b0f56eaf865245c7bcf8060963a088 (patch) | |
tree | 99f736e54839e356ee31705769dcd79fc5aa36ec | |
parent | ae228edc168d9300bb49f72b1388166691fbf20a (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
-rw-r--r-- | absl/time/duration.cc | 9 |
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; |