Closed leibrandt-telos closed 10 months ago
When running unit tests under valgrind there is an error highlighted:
➜ build valgrind --tool=memcheck --leak-check=full --track-origins=yes --error-exitcode=101 ./example-01_position ==47627== Memcheck, a memory error detector ==47627== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==47627== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info ==47627== Command: ./example-01_position ==47627== t | p1 | p2 | p3 ==47627== Conditional jump or move depends on uninitialised value(s) ==47627== at 0x11A0F9: bool std::__equal<false>::equal<double const*, double const*>(double const*, double const*, double const*) (stl_algobase.h:1162) ==47627== by 0x119137: bool std::__equal_aux1<double const*, double const*>(double const*, double const*, double const*) (stl_algobase.h:1211) ==47627== by 0x116592: bool std::__equal_aux<double const*, double const*>(double const*, double const*, double const*) (stl_algobase.h:1219) ==47627== by 0x111262: bool std::equal<double const*, double const*>(double const*, double const*, double const*) (stl_algobase.h:1556) ==47627== by 0x10F62D: bool std::operator==<double, 3ul>(std::array<double, 3ul> const&, std::array<double, 3ul> const&) (array:277) ==47627== by 0x10E42E: ruckig::InputParameter<3ul, ruckig::StandardVector>::operator!=(ruckig::InputParameter<3ul, ruckig::StandardVector> const&) const (input_parameter.hpp:364) ==47627== by 0x10D71C: ruckig::Ruckig<3ul, ruckig::StandardVector, false>::update(ruckig::InputParameter<3ul, ruckig::StandardVector> const&, ruckig::OutputParameter<3ul, ruckig::StandardVector>&) (ruckig.hpp:194) ==47627== by 0x10BA5F: main (01_position.cpp:29) ==47627== Uninitialised value was created by a stack allocation ==47627== at 0x10B6FE: main (01_position.cpp:8) ==47627==
The fix is trivial: In ruckig.hpp:194 Changing the the order of evaluation of the boolean expression, from:
ruckig.hpp:194
if (input != current_input || !current_input_initialized) {
to
if (!current_input_initialized || input != current_input ) {
will fix the issue as the second part input != current_input will only get evaluated after the values are initialized.
input != current_input
When running unit tests under valgrind there is an error highlighted:
The fix is trivial: In
ruckig.hpp:194
Changing the the order of evaluation of the boolean expression, from:to
will fix the issue as the second part
input != current_input
will only get evaluated after the values are initialized.