From ad0999022b63978a4b42d5e62b0c407ddedb5153 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Wed, 24 Nov 2021 11:24:01 -0500 Subject: [PATCH] Address PR comment --- cpp/src/unary/cast_ops.cu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/unary/cast_ops.cu b/cpp/src/unary/cast_ops.cu index 6bc066d8f76..131fde11cf8 100644 --- a/cpp/src/unary/cast_ops.cu +++ b/cpp/src/unary/cast_ops.cu @@ -331,7 +331,8 @@ struct dispatch_unary_cast_to { if constexpr (sizeof(SourceDeviceT) < sizeof(TargetDeviceT)) { // device_cast BEFORE rescale when SourceDeviceT is < TargetDeviceT - return detail::rescale(*casted(), scale_type{type.scale()}, stream, mr); + auto temporary = casted(); + return detail::rescale(*temporary, scale_type{type.scale()}, stream, mr); } else { // device_cast AFTER rescale when SourceDeviceT is > TargetDeviceT to avoid overflow auto temporary = detail::rescale(input, scale_type{type.scale()}, stream, mr);