Work around compiler bug returning an optional unique_ptr.

It looks like some compilers (e.g. gcc-7) don't like returning
a moveable value directly when the return type is `std::optional`
(i.e. it fails to treat the returned value as an r-value and
automatically construct an optional instance around it).
Explicitly creating the `std::optional` and returning _that_
seems to work around the issue.

PiperOrigin-RevId: 507062621
This commit is contained in:
Antonio Sanchez 2023-02-03 20:46:41 -08:00 committed by TensorFlower Gardener
parent 7a39261f92
commit f024cd92f6

View File

@ -455,7 +455,8 @@ class FftPlanCache {
cache_.erase(it);
}
--size_;
return value;
// Explicitly create an optional to avoid a compiler bug with gcc-7.
return std::optional<Value>(std::move(value));
}
// Inserts a plan into the cache as long as there is still capacity.