Skip to content

Commit

Permalink
core: Don't use -Wno-maybe-uninitialized, ignore the warning locally
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Jan 26, 2024
1 parent d9023ee commit eccd6f7
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ IF(BUILD_PYTHON_INTERFACE)
# -Wcomment as latex equations have multi-line comments.
# -Wself-assign-overloaded as bp::self operations trigger this (Clang only)
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU -Wno-conversion -Wno-comment -Wno-maybe-uninitialized
GNU -Wno-conversion -Wno-comment
CLANG -Wno-conversion -Wno-comment -Wno-self-assign-overloaded
OUTPUT PRIVATE_OPTIONS)
TARGET_COMPILE_OPTIONS(${PYWRAP} PRIVATE ${PRIVATE_OPTIONS})
Expand Down
5 changes: 0 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ FUNCTION(ADD_PINOCCHIO_CPP_EXAMPLE EXAMPLE)
ADD_UNIT_TEST(${EXAMPLE_NAME} "${EXAMPLE}.cpp")
TARGET_LINK_LIBRARIES(${EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})

CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU -Wno-maybe-uninitialized
OUTPUT PRIVATE_OPTIONS)
TARGET_COMPILE_OPTIONS(${EXAMPLE_NAME} PRIVATE ${PRIVATE_OPTIONS})

CXX_FLAGS_BY_COMPILER_FRONTEND(
MSVC _USE_MATH_DEFINES
OUTPUT PRIVATE_DEFINITIONS)
Expand Down
1 change: 1 addition & 0 deletions examples/overview-lie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ int main()
SE2Operation aSE2;
SE2Operation::ConfigVector_t pose_s,pose_g;
SE2Operation::TangentVector_t delta_u;
delta_u.setZero();

// Starting configuration
pose_s(0) = 1.0; pose_s(1) = 1.0;
Expand Down
9 changes: 9 additions & 0 deletions include/pinocchio/multibody/liegroup/liegroup-base.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,11 @@ namespace pinocchio {
const AssignmentOperatorType op) const
{
Index nv_ (nv());
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
JacobianMatrix_t J (nv_, nv_);
dIntegrate(q, v, J, arg);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
switch (op) {
case SETTO:
if(dIntegrateOnTheLeft) Jout = J * Jin;
Expand All @@ -585,8 +588,11 @@ namespace pinocchio {
const AssignmentOperatorType op) const
{
Index nv_ (nv());
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
JacobianMatrix_t J (nv_, nv_);
dDifference<arg>(q0, q1, J);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
switch (op) {
case SETTO:
if(dDifferenceOnTheLeft) Jout = J * Jin;
Expand Down Expand Up @@ -627,8 +633,11 @@ namespace pinocchio {
const Eigen::MatrixBase<ConfigL_t> & q0,
const Eigen::MatrixBase<ConfigR_t> & q1) const
{
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
TangentVector_t t(nv());
difference(q0.derived(), q1.derived(), t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
return t.squaredNorm();
}

Expand Down
39 changes: 39 additions & 0 deletions include/pinocchio/multibody/liegroup/special-euclidean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,11 @@ namespace pinocchio
Vector2 t (R0.transpose() * (t1 - t0));

if (arg == ARG0) {
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
JacobianMatrix_t J1;
Jlog (R, t, J1);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

// pcross = [ y1-y0, - (x1 - x0) ]
Vector2 pcross (q1(1) - q0(1), q0(0) - q1(0));
Expand All @@ -267,10 +270,13 @@ namespace pinocchio
{
ConfigOut_t & out = PINOCCHIO_EIGEN_CONST_CAST(ConfigOut_t,qout);

PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix2 R0, R;
Vector2 t0, t;
forwardKinematics(R0, t0, q);
exp(v, R, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

out.template head<2>().noalias() = R0 * t + t0;
out.template tail<2>().noalias() = R0 * R.col(0);
Expand Down Expand Up @@ -300,9 +306,12 @@ namespace pinocchio
{
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J);

PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix2 R;
Vector2 t;
exp(v, R, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

toInverseActionMatrix(R, t, Jout, op);
}
Expand All @@ -316,8 +325,11 @@ namespace pinocchio
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J);
// TODO sparse version
MotionTpl<Scalar,0> nu; nu.toVector() << v.template head<2>(), 0, 0, 0, v[2];
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,6,6> Jtmp6;
Jexp6(nu, Jtmp6);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

switch(op)
{
Expand Down Expand Up @@ -350,9 +362,12 @@ namespace pinocchio
const Eigen::MatrixBase<JacobianOut_t> & J_out) const
{
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J_out);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix2 R;
Vector2 t;
exp(v, R, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

Vector2 tinv = (R.transpose() * t).reverse();
tinv[0] *= Scalar(-1.);
Expand All @@ -371,8 +386,11 @@ namespace pinocchio
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J_out);
MotionTpl<Scalar,0> nu; nu.toVector() << v.template head<2>(), 0, 0, 0, v[2];

PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,6,6> Jtmp6;
Jexp6(nu, Jtmp6);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

Jout.template topRows<2>().noalias()
= Jtmp6.template topLeftCorner<2,2>() * Jin.template topRows<2>();
Expand All @@ -391,9 +409,12 @@ namespace pinocchio
const Eigen::MatrixBase<Jacobian_t> & J) const
{
Jacobian_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t,J);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix2 R;
Vector2 t;
exp(v, R, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

Vector2 tinv = (R.transpose() * t).reverse();
tinv[0] *= Scalar(-1);
Expand All @@ -411,8 +432,11 @@ namespace pinocchio
Jacobian_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t,J);
MotionTpl<Scalar,0> nu; nu.toVector() << v.template head<2>(), 0, 0, 0, v[2];

PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,6,6> Jtmp6;
Jexp6(nu, Jtmp6);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
//TODO: Remove aliasing
Jout.template topRows<2>()
= Jtmp6.template topLeftCorner<2,2>() * Jout.template topRows<2>();
Expand Down Expand Up @@ -570,8 +594,11 @@ namespace pinocchio
* SE3(R1, q1.template head<3>()));

if (arg == ARG0) {
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
JacobianMatrix_t J1;
Jlog6 (M, J1);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

const Vector3 p1_p0 = R1.transpose()*(q1.template head<3>() - q0.template head<3>());

Expand Down Expand Up @@ -638,13 +665,16 @@ namespace pinocchio

typedef Eigen::Matrix<Scalar,4,3,JacobianPlainType::Options|Eigen::RowMajor> Jacobian43;
typedef SE3Tpl<Scalar,ConfigPlainType::Options> SE3;
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Jacobian43 Jexp3QuatCoeffWise;

Scalar theta;
typename SE3::Vector3 v = quaternion::log3(quat_map,theta);
quaternion::Jexp3CoeffWise(v,Jexp3QuatCoeffWise);
typename SE3::Matrix3 Jlog;
Jlog3(theta,v,Jlog);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

// std::cout << "Jexp3QuatCoeffWise\n" << Jexp3QuatCoeffWise << std::endl;
// std::cout << "Jlog\n" << Jlog << std::endl;
Expand Down Expand Up @@ -729,8 +759,11 @@ namespace pinocchio
const Eigen::MatrixBase<JacobianOut_t> & J_out) const
{
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J_out);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,6,6> Jtmp6;
Jexp6<SETTO>(MotionRef<const Tangent_t>(v.derived()), Jtmp6);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

Jout.template topRows<3>().noalias()
= Jtmp6.template topLeftCorner<3,3>() * Jin.template topRows<3>();
Expand Down Expand Up @@ -765,8 +798,11 @@ namespace pinocchio
const Eigen::MatrixBase<Jacobian_t> & J_out) const
{
Jacobian_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t,J_out);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,6,6> Jtmp6;
Jexp6<SETTO>(MotionRef<const Tangent_t>(v.derived()), Jtmp6);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

Jout.template topRows<3>()
= Jtmp6.template topLeftCorner<3,3>() * Jout.template topRows<3>();
Expand All @@ -780,8 +816,11 @@ namespace pinocchio
static Scalar squaredDistance_impl(const Eigen::MatrixBase<ConfigL_t> & q0,
const Eigen::MatrixBase<ConfigR_t> & q1)
{
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
TangentVector_t t;
difference_impl(q0, q1, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
return t.squaredNorm();
}

Expand Down
15 changes: 15 additions & 0 deletions include/pinocchio/multibody/liegroup/special-orthogonal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,11 @@ namespace pinocchio
const Quaternion_t quat_diff = quat0.conjugate() * quat1;

if (arg == ARG0) {
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
JacobianMatrix_t J1;
quaternion::Jlog3(quat_diff, J1);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
const Matrix3 R = (quat_diff).matrix();

PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J).noalias() = - J1 * R.transpose();
Expand Down Expand Up @@ -439,13 +442,16 @@ namespace pinocchio
ConstQuaternionMap_t quat_map(q.derived().data());
assert(quaternion::isNormalized(quat_map,RealScalar(PINOCCHIO_DEFAULT_QUATERNION_NORM_TOLERANCE_VALUE)));

PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Eigen::Matrix<Scalar,NQ,NV,JacobianPlainType::Options|Eigen::RowMajor> Jexp3QuatCoeffWise;

Scalar theta;
const Vector3 v = quaternion::log3(quat_map,theta);
quaternion::Jexp3CoeffWise(v,Jexp3QuatCoeffWise);
Matrix3 Jlog;
Jlog3(theta,v,Jlog);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP

// if(quat_map.w() >= 0.) // comes from the log3 for quaternions which may change the sign.
if(quat_map.coeffs()[3] >= 0.) // comes from the log3 for quaternions which may change the sign.
Expand Down Expand Up @@ -523,8 +529,11 @@ namespace pinocchio
{
typedef typename SE3::Matrix3 Matrix3;
JacobianOut_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(JacobianOut_t,J_out);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix3 Jtmp3;
Jexp3<SETTO>(v, Jtmp3);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
Jout.noalias() = Jtmp3 * Jin;
}

Expand All @@ -546,8 +555,11 @@ namespace pinocchio
{
typedef typename SE3::Matrix3 Matrix3;
Jacobian_t & Jout = PINOCCHIO_EIGEN_CONST_CAST(Jacobian_t,J_out);
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix3 Jtmp3;
Jexp3<SETTO>(v, Jtmp3);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
Jout = Jtmp3 * Jout;
}

Expand All @@ -573,8 +585,11 @@ namespace pinocchio
static Scalar squaredDistance_impl(const Eigen::MatrixBase<ConfigL_t> & q0,
const Eigen::MatrixBase<ConfigR_t> & q1)
{
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
TangentVector_t t;
difference_impl(q0, q1, t);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
return t.squaredNorm();
}

Expand Down
6 changes: 6 additions & 0 deletions include/pinocchio/spatial/explog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,11 @@ namespace pinocchio
}
case ADDTO:
{
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix3 Jtmp3;
Jexp3<SETTO>(w, Jtmp3);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
Jout.template bottomRightCorner<3,3>() += Jtmp3;
Jout.template topLeftCorner<3,3>() += Jtmp3;
const Vector3 p = Jtmp3.transpose() * v;
Expand All @@ -502,8 +505,11 @@ namespace pinocchio
}
case RMTO:
{
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Matrix3 Jtmp3;
Jexp3<SETTO>(w, Jtmp3);
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
Jout.template bottomRightCorner<3,3>() -= Jtmp3;
Jout.template topLeftCorner<3,3>() -= Jtmp3;
const Vector3 p = Jtmp3.transpose() * v;
Expand Down
8 changes: 1 addition & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ MODERNIZE_TARGET_LINK_LIBRARIES(${PROJECT_NAME}_headers SCOPE INTERFACE
INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}_headers INTERFACE $<INSTALL_INTERFACE:include>)

# Do not report:
# -Wmaybe-uninitialized as Eigen const_cast_derived hack trigger this
CXX_FLAGS_BY_COMPILER_FRONTEND(
MSVC "/bigobj"
OUTPUT PUBLIC_OPTIONS)
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU -Wno-maybe-uninitialized
OUTPUT PRIVATE_OPTIONS)
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC ${PUBLIC_OPTIONS}
PRIVATE ${PRIVATE_OPTIONS})
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC ${PUBLIC_OPTIONS})

SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
IF(BUILD_WITH_COMMIT_VERSION)
Expand Down
19 changes: 12 additions & 7 deletions unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
# --- MACROS ------------------------------------------------------------------
# --- MACROS ------------------------------------------------------------------

MACRO(ADD_TEST_CFLAGS target flag)
SET_PROPERTY(TARGET "test-cpp-${target}" APPEND_STRING PROPERTY COMPILE_FLAGS " ${flag}")
MACRO(ADD_TEST_CFLAGS target)
foreach(ARG ${ARGN})
SET_PROPERTY(TARGET "test-cpp-${target}" APPEND_STRING PROPERTY COMPILE_FLAGS "${ARG} ")
endforeach()
ENDMACRO(ADD_TEST_CFLAGS)

MACRO(ADD_PINOCCHIO_UNIT_TEST NAME)
Expand All @@ -23,11 +25,6 @@ MACRO(ADD_PINOCCHIO_UNIT_TEST NAME)
SET(TEST_NAME "test-cpp-${NAME}")
ADD_UNIT_TEST(${TEST_NAME} ${NAME}.cpp)

CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU -Wno-maybe-uninitialized
OUTPUT PRIVATE_OPTIONS)
TARGET_COMPILE_OPTIONS(${TEST_NAME} PRIVATE ${PRIVATE_OPTIONS})

CXX_FLAGS_BY_COMPILER_FRONTEND(
MSVC _USE_MATH_DEFINES
OUTPUT PRIVATE_DEFINITIONS)
Expand Down Expand Up @@ -167,7 +164,15 @@ ADD_PINOCCHIO_UNIT_TEST(finite-differences)
ADD_PINOCCHIO_UNIT_TEST(visitor)
ADD_PINOCCHIO_UNIT_TEST(algo-check)

# Warning ignore with pragma doesn't work for
# a part of this test, so we ignore two warning
# globally
CXX_FLAGS_BY_COMPILER_FRONTEND(
GNU -Wno-maybe-uninitialized -Wuse-after-free=0
OUTPUT LIEGROUPS_OPTIONS)
ADD_PINOCCHIO_UNIT_TEST(liegroups)
ADD_TEST_CFLAGS(liegroups ${LIEGROUPS_OPTIONS})

ADD_PINOCCHIO_UNIT_TEST(cartesian-product-liegroups)
ADD_PINOCCHIO_UNIT_TEST(regressor)
ADD_PINOCCHIO_UNIT_TEST(version)
Expand Down
Loading

0 comments on commit eccd6f7

Please sign in to comment.