Skip to content

Commit 3b0ea95

Browse files
Merge pull request #2217 from oscardssmith/fix-default-ub
initialize bitstype caches in `DefaultCache`
2 parents 195fe78 + cd33f52 commit 3b0ea95

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/caches/basic_caches.jl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,29 @@ function alg_cache(alg::CompositeAlgorithm{CS, Tuple{A1, A2, A3, A4, A5, A6}}, u
5959
T4 = Base.promote_op(alg_cache, A4, argT...)
6060
T5 = Base.promote_op(alg_cache, A5, argT...)
6161
T6 = Base.promote_op(alg_cache, A6, argT...)
62-
DefaultCache{T1, T2, T3, T4, T5, T6, typeof(alg.choice_function)}(
62+
cache = DefaultCache{T1, T2, T3, T4, T5, T6, typeof(alg.choice_function)}(
6363
args, alg.choice_function, 1)
64+
algs = alg.algs
65+
# If the type is a bitstype we need to initialize it correctly here since isdefined will always return true.
66+
if isbitstype(T1)
67+
cache.cache1 = alg_cache(algs[1], args...)
68+
end
69+
if isbitstype(T2)
70+
cache.cache2 = alg_cache(algs[2], args...)
71+
end
72+
if isbitstype(T3)
73+
cache.cache3 = alg_cache(algs[3], args...)
74+
end
75+
if isbitstype(T4)
76+
cache.cache4 = alg_cache(algs[4], args...)
77+
end
78+
if isbitstype(T5)
79+
cache.cache5 = alg_cache(algs[5], args...)
80+
end
81+
if isbitstype(T6)
82+
cache.cache6 = alg_cache(algs[6], args...)
83+
end
84+
cache
6485
end
6586

6687
# map + closure approach doesn't infer

0 commit comments

Comments
 (0)