Skip to content

Commit e240c08

Browse files
committed
Fix: don't use moved-from variable for sizing
1 parent 475a022 commit e240c08

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stan/math/prim/functor/apply_scalar_binary.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ template <typename F, typename T1, typename T2,
306306
inline auto apply_scalar_binary(F&& f, T1&& x, T2&& y) {
307307
decltype(auto) x_vec = as_column_vector_or_scalar(std::forward<T1>(x));
308308
using T_return = std::decay_t<decltype(f(x[0], y))>;
309-
std::vector<T_return> result(x.size());
309+
std::vector<T_return> result(x_vec.size());
310310
Eigen::Map<Eigen::Matrix<T_return, -1, 1>>(result.data(), result.size())
311311
= x_vec.unaryExpr(
312312
[f_ = std::forward<F>(f), y](auto&& v) { return f_(v, y); });
@@ -337,7 +337,7 @@ template <typename F, typename T1, typename T2,
337337
inline auto apply_scalar_binary(F&& f, T1&& x, T2&& y) {
338338
decltype(auto) y_vec = as_column_vector_or_scalar(y);
339339
using T_return = std::decay_t<decltype(f(x, y[0]))>;
340-
std::vector<T_return> result(y.size());
340+
std::vector<T_return> result(y_vec.size());
341341
Eigen::Map<Eigen::Matrix<T_return, -1, 1>>(result.data(), result.size())
342342
= y_vec.unaryExpr(
343343
[f_ = std::forward<F>(f), x](auto&& v) { return f_(x, v); });

0 commit comments

Comments
 (0)