Commit a5be9df
committed
fix(reduce_sum_static): wrap Args with ref_type_t to materialize Eigen expressions
reduce_sum has been wrapping shared Args with ref_type_t<Args&&>... since
v4.8+ so that Eigen expression-template temporaries (e.g. M.row(0),
matrix.col(i)) materialize before being handed off to TBB's parallel
reducer. reduce_sum_static's STAN_THREADS branch was not updated in the
same pass and still forwarded plain Args..., so callers passing a
temporary Eigen expression as a shared argument could get a dangling
reference once the temporary went out of scope.
Mirror the reduce_sum wrapping exactly:
internal::reduce_sum_impl<..., ref_type_t<Args&&>...>()(...)
No other changes. ref_type_t is already in scope via
stan/math/prim/meta.hpp (already included).
Closes #33041 parent ac8c21a commit a5be9df
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
0 commit comments