From edfa27d837a61e92ca30325465d7ebf9bdcd825c Mon Sep 17 00:00:00 2001 From: conrad Date: Sat, 18 Oct 2025 14:29:18 +1000 Subject: [PATCH] skip alias check if element types differ --- include/armadillo_bits/unwrap.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/armadillo_bits/unwrap.hpp b/include/armadillo_bits/unwrap.hpp index 0026afd0..6f9fe076 100644 --- a/include/armadillo_bits/unwrap.hpp +++ b/include/armadillo_bits/unwrap.hpp @@ -396,7 +396,7 @@ struct quasi_unwrap< subview_row > static constexpr bool has_orig_mem = false; // NOTE: set to false as this is the general case; original memory is only used when the subview is a contiguous chunk template - arma_inline bool is_alias(const Mat& X) const { return (sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false; } + arma_inline bool is_alias(const Mat& X) const { return (is_same_type::yes) && ((sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false); } }; @@ -1441,7 +1441,7 @@ struct partial_unwrap< subview_row > constexpr eT get_val() const { return eT(1); } template - arma_inline bool is_alias(const Mat& X) const { return (sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false; } + arma_inline bool is_alias(const Mat& X) const { return (is_same_type::yes) && ((sv.m.n_rows == 1) ? (void_ptr(&X) == void_ptr(&(sv.m))) : false); } static constexpr bool do_trans = false; static constexpr bool do_times = false;