-
-
Notifications
You must be signed in to change notification settings - Fork 512
Description
To the best of my knowledge, the following two code snippets (where mat
is an owned mutable nalgebra Matrix) should produce the same final result:
// Clean version
mat.swap_rows(r1, r2);
// Ugly version
let row1 = mat.fixed_rows::<U1>(r1).into_owned();
let row2 = mat.fixed_rows::<U1>(r2).into_owned();
mat.fixed_rows_mut::<U1>(r1).copy_from(&row2);
mat.fixed_rows_mut::<U1>(r2).copy_from(&row1);
Unfortunately, I have a program where the former produces different (and wrong) results, with suspiciously UB-ish symptoms: if I add a print statement near the code that does the swap_rows, the results become correct.
I do not use unsafe myself, so I can only assume that the issue is in nalgebra. But looking at the source code of swap_rows did not reveal anything suspicious, and I was not successful in producing a simpler reproducer that I can share with you so far.
If you have more experience in debugging this kind of issues than I do, any tips on how to narrow down the problem further would be much appreciated.