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
diff --git a/absl/time/duration.cc b/absl/time/duration.cc
index 4443109..2bba62d 100644
--- a/absl/time/duration.cc
+++ b/absl/time/duration.cc
@@ -766,13 +766,14 @@
// 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;