From 2535e312b16ecb98939b8fe6f18ba7226a4e2e5d Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Wed, 5 Jul 2017 05:30:13 -0400 Subject: [PATCH] Use a local buffer in `modf` Fix #21591 --- base/math.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/base/math.jl b/base/math.jl index d12bf8860c8b56..2a3082e2491167 100644 --- a/base/math.jl +++ b/base/math.jl @@ -695,16 +695,16 @@ julia> modf(3.5) """ modf(x) = rem(x,one(x)), trunc(x) -const _modff_temp = Ref{Float32}() function modf(x::Float32) - f = ccall((:modff,libm), Float32, (Float32,Ptr{Float32}), x, _modff_temp) - f, _modff_temp[] + temp = Ref{Float32}() + f = ccall((:modff, libm), Float32, (Float32, Ptr{Float32}), x, temp) + f, temp[] end -const _modf_temp = Ref{Float64}() function modf(x::Float64) - f = ccall((:modf,libm), Float64, (Float64,Ptr{Float64}), x, _modf_temp) - f, _modf_temp[] + temp = Ref{Float64}() + f = ccall((:modf, libm), Float64, (Float64, Ptr{Float64}), x, temp) + f, temp[] end @inline ^(x::Float64, y::Float64) = nan_dom_err(ccall("llvm.pow.f64", llvmcall, Float64, (Float64, Float64), x, y), x + y)