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
pull/1200/head
Derek Mauro 2 years ago committed by Copybara-Service
parent ae228edc16
commit 2e36d96669
  1. 9
      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;

Loading…
Cancel
Save