Skip to content

Fix multistagestepsol tpl

Reinhard Resch requested to merge fix-multistagestepsol_tpl into develop

Fix -Werror=aggressive-loop-optimizations due to potential out of bound array access, although it cannot happen at runtime.

In file included from /home/gitlab-runner/builds/RmToRsLxL/0/DAER/mbdyn/mbdyn/base/multistagestepsol_impl.h:51,
                 from /home/gitlab-runner/builds/RmToRsLxL/0/DAER/mbdyn/mbdyn/base/multistagestepsol_impl.cc:44:
/home/gitlab-runner/builds/RmToRsLxL/0/DAER/mbdyn/mbdyn/base/multistagestepsol_tpl.h: In member function 'void tplStageNIntegrator<N>::PredictDofForStageS(int, DofOrder::Order, const VectorHandler*) const [with unsigned int S = 5; unsigned int N = 2]':
/home/gitlab-runner/builds/RmToRsLxL/0/DAER/mbdyn/mbdyn/base/multistagestepsol_tpl.h:225:41: error: iteration 2 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
  225 |                         dXm1mN[i] = m_pX[i]->operator()(DCount);
      |                                     ~~~~^
/home/gitlab-runner/builds/RmToRsLxL/0/DAER/mbdyn/mbdyn/base/multistagestepsol_tpl.h:224:40: note: within this loop
  224 |                 for (unsigned i = 0; i < S; i++) {
      |                                      ~~^~~
Edited by Reinhard Resch

Merge request reports