Ifpack2: dangerous shadowing in Details::MultiVectorLocalGatherScatter
Created by: jhux2
@trilinos/ifpack2 In Ifpack2_Details_MultiVectorLocalGatherScatter.hpp in the gatherMVtoView method, there is this code:
170 for(LO i = 0; i < perm.size(); ++i)
171 //note: j is col, i is row
172 for(size_t j = 0; j < X_out.getNumVectors(); ++j) {
173 Teuchos::ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
174 for(size_t i = 0; i < X_out.getLocalLength(); ++i) {
175 const LO i_perm = perm[i];
176 X_out_j[i] = X_in(i_perm, j);
177 }
178 }
179 }
The inner use of i
is shadowed by the outer. This looks dangerous.
I thought this would be the proper fix:
170 for(LO i = 0; i < perm.size(); ++i)
171 //note: j is col, i is row
172 for(size_t j = 0; j < X_out.getNumVectors(); ++j) {
173 Teuchos::ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
174 for(size_t k = 0; k < X_out.getLocalLength(); ++k) {
175 const LO i_perm = perm[i];
176 X_out_j[k] = X_in(i_perm, j);
177 }
178 }
179 }
However, SparseContainer_double_int_int_ILUT_UnitTest
fails when I make that change.
I had hoped to fix this while simultaneously pushing an unrelated change to MueLu, but no dice.