From b3f4e5560477fa8d6f03d41ff60c53ea8a341eb5 Mon Sep 17 00:00:00 2001 From: conrad Date: Thu, 14 Nov 2024 19:25:01 +1000 Subject: [PATCH] check for aliasing only when the element types match --- include/armadillo_bits/unwrap.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/armadillo_bits/unwrap.hpp b/include/armadillo_bits/unwrap.hpp index 7e936317..b6be60bc 100644 --- a/include/armadillo_bits/unwrap.hpp +++ b/include/armadillo_bits/unwrap.hpp @@ -1075,8 +1075,8 @@ struct unwrap_check_mixed< Mat > template inline unwrap_check_mixed(const Mat& A, const Mat& B) - : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat(A) : nullptr ) - , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) + : M_local( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? new Mat(A) : nullptr ) + , M ( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? (*M_local) : A ) { arma_debug_sigprint(); } @@ -1112,8 +1112,8 @@ struct unwrap_check_mixed< Row > template inline unwrap_check_mixed(const Row& A, const Mat& B) - : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row(A) : nullptr ) - , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) + : M_local( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? new Row(A) : nullptr ) + , M ( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? (*M_local) : A ) { arma_debug_sigprint(); } @@ -1150,8 +1150,8 @@ struct unwrap_check_mixed< Col > template inline unwrap_check_mixed(const Col& A, const Mat& B) - : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col(A) : nullptr ) - , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A ) + : M_local( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? new Col(A) : nullptr ) + , M ( ((is_same_type::yes) && (void_ptr(&A) == void_ptr(&B))) ? (*M_local) : A ) { arma_debug_sigprint(); }