Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GCC 13 warnings #1978

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Fix GCC 13 warnings #1978

merged 1 commit into from
Jan 23, 2025

Conversation

Gold856
Copy link
Contributor

@Gold856 Gold856 commented Jan 14, 2025

Fixes #1967 and fixes #1981.

@Gold856

This comment was marked as outdated.

@Gold856

This comment was marked as outdated.

.github/workflows/build-linux.yml Outdated Show resolved Hide resolved
@@ -9,6 +9,10 @@
#include <gtsam/geometry/FundamentalMatrix.h>
#include <gtsam/geometry/Point2.h>

#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the simplest solution for now, but it is nice that in Eigen 3.4 the SVD implementations have an info() method that can be used to check it and fix the uninitialized warning.

Eigen::JacobiSVD<Matrix3> svd(F, Eigen::ComputeFullU | Eigen::ComputeFullV);
if (svd.info() != Eigen::ComputationInfo::Success) {
    throw std::runtime_error("FundamentalMatrix::FundamentalMatrix unsuccessful svd computation");
}

@mcm001
Copy link
Contributor

mcm001 commented Jan 21, 2025

Yeah my take is that these warnings seem spurious (in most cases -- at least those we found in this MR, with the exception of examples/TriangulationLOSTExample.cpp), and we should build with -Wno-error=maybe-uninitialized -Wno-error=array-bounds by default actually. Happy to PR that if we'd like.

@dellaert
Copy link
Member

Yeah my take is that these warnings seem spurious (in most cases -- at least those we found in this MR, with the exception of examples/TriangulationLOSTExample.cpp), and we should build with -Wno-error=maybe-uninitialized -Wno-error=array-bounds by default actually. Happy to PR that if we'd like.

Globally? That seems too dangerous. I’m already queasy with a file-level exception :-)

After you remove the workflow edits, however, I’m ok with the PR as is. We should then open an issue to look more closely as to what’s happening.

@dellaert
Copy link
Member

Your proposed edit is way better - in that it kills the pragmas.

@Gold856
Copy link
Contributor Author

Gold856 commented Jan 21, 2025

Getting this set of errors when building all.tests:

FAILED: gtsam/basis/tests/CMakeFiles/testFourier.dir/testFourier.cpp.o
/usr/bin/c++ -DNDEBUG -DTOPSRCDIR=\"/home/gold856/gtsam\" -I/home/gold856/gtsam -I/home/gold856/gtsam/build -I/home/gold856/gtsam/CppUnitLite -I/home/gold856/gtsam/gtsam/3rdparty/metis/include -I/home/gold856/gtsam/gtsam/3rdparty/metis/libmetis -I/home/gold856/gtsam/gtsam/3rdparty/metis/GKlib -I/home/gold856/gtsam/gtsam/3rdparty/cephes -isystem /home/gold856/gtsam/gtsam/3rdparty/SuiteSparse_config -isystem /home/gold856/gtsam/gtsam/3rdparty/Spectra -isystem /home/gold856/gtsam/gtsam/3rdparty/CCOLAMD/Include -isystem /home/gold856/gtsam/gtsam/3rdparty/Eigen -O3 -DNDEBUG -std=c++17 -fPIE -fdiagnostics-color=always -Werror -Wall -Wpedantic -Wextra -Wno-unused-parameter -Wreturn-local-addr -Wreturn-type -Wformat -Werror=format-security -Wsuggest-override -O3 -Wno-unused-local-typedefs -MD -MT gtsam/basis/tests/CMakeFiles/testFourier.dir/testFourier.cpp.o -MF gtsam/basis/tests/CMakeFiles/testFourier.dir/testFourier.cpp.o.d -o gtsam/basis/tests/CMakeFiles/testFourier.dir/testFourier.cpp.o -c /home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp
In file included from /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/util/ConfigureVectorization.h:346,
                 from /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/Core:22,
                 from /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/Dense:1,
                 from /home/gold856/gtsam/gtsam/base/OptionalJacobian.h:24,
                 from /home/gold856/gtsam/gtsam/base/Matrix.h:27,
                 from /home/gold856/gtsam/gtsam/basis/Basis.h:21,
                 from /home/gold856/gtsam/gtsam/basis/FitBasis.h:27,
                 from /home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp:21:
In function ‘__m128d _mm_loadu_pd(const double*)’,
    inlined from ‘Packet Eigen::internal::ploadu(const typename unpacket_traits<T>::type*) [with Packet = __vector(2) double]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/arch/SSE/PacketMath.h:746:22,
    inlined from ‘Packet Eigen::internal::ploadt(const typename unpacket_traits<T>::type*) [with Packet = __vector(2) double; int Alignment = 0]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/GenericPacketMath.h:969:26,
    inlined from ‘PacketType Eigen::internal::evaluator<Eigen::PlainObjectBase<Derived> >::packet(Eigen::Index) const [with int LoadMode = 0; PacketType = __vector(2) double; Derived = Eigen::Matrix<double, 1, 1, 0, 1, 1>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/CoreEvaluators.h:245:40,
    inlined from ‘void Eigen::internal::generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>::assignPacket(Eigen::Index)[with int StoreMode = 16; int LoadMode = 0; PacketType = __vector(2) double; DstEvaluatorTypeT = Eigen::internal::evaluator<Eigen::Matrix<double, -1, -1> >; SrcEvaluatorTypeT = Eigen::internal::evaluator<Eigen::Matrix<double, 1, 1, 0, 1, 1> >; Functor = Eigen::internal::assign_op<double, double>; int Version = 0]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:681:114,
    inlined from ‘static void Eigen::internal::dense_assignment_loop<Kernel, 3, 0>::run(Kernel&) [with Kernel = Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, -1, -1> >, Eigen::internal::evaluator<Eigen::Matrix<double, 1, 1, 0, 1, 1> >, Eigen::internal::assign_op<double, double>, 0>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:437:75,
    inlined from ‘void Eigen::internal::call_dense_assignment_loop(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Matrix<double, -1, -1>; SrcXprType = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Functor = assign_op<double, double>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:785:37,
    inlined from ‘static void Eigen::internal::Assignment<DstXprType, SrcXprType, Functor, Eigen::internal::Dense2Dense, Weak>::run(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Matrix<double, -1, -1>; SrcXprType = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Functor = Eigen::internal::assign_op<double, double>; Weak = void]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:954:31,
    inlined from ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<double, -1, -1>; Src = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Func = assign_op<double, double>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:890:49,
    inlined from ‘Derived& Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Derived = Eigen::Matrix<double, -1, -1>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/PlainObjectBase.h:797:41,
    inlined from ‘Eigen::PlainObjectBase<Derived>::PlainObjectBase(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Derived = Eigen::Matrix<double, -1, -1>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/PlainObjectBase.h:594:19,
    inlined from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; _Scalar = double; int _Rows = -1; int _Cols = -1; int _Options = 0; int _MaxRows = -1; int _MaxCols = -1]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/Matrix.h:423:29,
    inlined from ‘virtual void BasisDerivative7Test::run(TestResult&)’ at /home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp:168:71:
/usr/lib/gcc/x86_64-linux-gnu/13/include/emmintrin.h:134:24: error: array subscript ‘__m128d_u[0]’ is partly outside array bounds of ‘gtsam::internal::FixedSizeMatrix<double, double>::type [1]’ {aka ‘Eigen::Matrix<double, 1, 1, 0, 1, 1> [1]’} [-Werror=array-bounds=]
  134 |   return *(__m128d_u *)__P;
      |                        ^~~
/home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp: In member function ‘virtual void BasisDerivative7Test::run(TestResult&)’:
/home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp:168:62: note: object ‘<anonymous>’ of size 8
  168 |   Matrix numeric_dTdx = numericalDerivative11<double, double>(proxy, x);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
In function ‘void _mm_store_pd(double*, __m128d)’,
    inlined from ‘void Eigen::internal::pstore(Scalar*, const Packet&) [with Scalar = double; Packet = __vector(2) double]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/arch/SSE/PacketMath.h:790:126,
    inlined from ‘void Eigen::internal::pstoret(Scalar*, const Packet&) [with Scalar = double; Packet = __vector(2) double; int Alignment = 16]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/GenericPacketMath.h:978:11,
    inlined from ‘void Eigen::internal::assign_op<DstScalar, SrcScalar>::assignPacket(DstScalar*, const Packet&) const [with int Alignment = 16; Packet = __vector(2) double; DstScalar = double; SrcScalar = double]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/functors/AssignmentFunctors.h:28:50,
    inlined from ‘void Eigen::internal::generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>::assignPacket(Eigen::Index)[with int StoreMode = 16; int LoadMode = 0; PacketType = __vector(2) double; DstEvaluatorTypeT = Eigen::internal::evaluator<Eigen::Matrix<double, -1, -1> >; SrcEvaluatorTypeT = Eigen::internal::evaluator<Eigen::Matrix<double, 1, 1, 0, 1, 1> >; Functor = Eigen::internal::assign_op<double, double>; int Version = 0]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:681:47,
    inlined from ‘static void Eigen::internal::dense_assignment_loop<Kernel, 3, 0>::run(Kernel&) [with Kernel = Eigen::internal::generic_dense_assignment_kernel<Eigen::internal::evaluator<Eigen::Matrix<double, -1, -1> >, Eigen::internal::evaluator<Eigen::Matrix<double, 1, 1, 0, 1, 1> >, Eigen::internal::assign_op<double, double>, 0>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:437:75,
    inlined from ‘void Eigen::internal::call_dense_assignment_loop(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Matrix<double, -1, -1>; SrcXprType = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Functor = assign_op<double, double>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:785:37,
    inlined from ‘static void Eigen::internal::Assignment<DstXprType, SrcXprType, Functor, Eigen::internal::Dense2Dense, Weak>::run(DstXprType&, const SrcXprType&, const Functor&) [with DstXprType = Eigen::Matrix<double, -1, -1>; SrcXprType = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Functor = Eigen::internal::assign_op<double, double>; Weak = void]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:954:31,
    inlined from ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<double, -1, -1>; Src = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Func = assign_op<double, double>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/AssignEvaluator.h:890:49,
    inlined from ‘Derived& Eigen::PlainObjectBase<Derived>::_set_noalias(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Derived = Eigen::Matrix<double, -1, -1>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/PlainObjectBase.h:797:41,
    inlined from ‘Eigen::PlainObjectBase<Derived>::PlainObjectBase(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; Derived = Eigen::Matrix<double, -1, -1>]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/PlainObjectBase.h:594:19,
    inlined from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::EigenBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<double, 1, 1, 0, 1, 1>; _Scalar = double; int _Rows = -1; int _Cols = -1; int _Options = 0; int _MaxRows = -1; int _MaxCols = -1]’ at /home/gold856/gtsam/gtsam/3rdparty/Eigen/Eigen/src/Core/Matrix.h:423:29,
    inlined from ‘virtual void BasisDerivative7Test::run(TestResult&)’ at /home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp:168:71:
/usr/lib/gcc/x86_64-linux-gnu/13/include/emmintrin.h:169:19: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ reading 16 or more bytes from a region of size 8 [-Werror=stringop-overread]
  169 |   *(__m128d *)__P = __A;
      |   ~~~~~~~~~~~~~~~~^~~~~
/home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp: In member function ‘virtual void BasisDerivative7Test::run(TestResult&)’:
/home/gold856/gtsam/gtsam/basis/tests/testFourier.cpp:168:62: note: source object ‘<anonymous>’ of size 8
  168 |   Matrix numeric_dTdx = numericalDerivative11<double, double>(proxy, x);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

The stringop-overread warning is new. I really do think we should use -Wno-error=maybe-uninitialized -Wno-error=array-bounds though. It's a bit icky, but it still prints the warnings, without causing the entire build to fail. We can always file some issues to fix them later.

@Gold856 Gold856 force-pushed the fix-warnings branch 2 times, most recently from 4591e01 to 1f89665 Compare January 21, 2025 08:16
@varunagrawal
Copy link
Collaborator

Quick question: are you only seeing this on GCC?
There is an old bug report which claims that the -Warray-bound warning is spurious: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456

@Gold856
Copy link
Contributor Author

Gold856 commented Jan 21, 2025

I haven’t tried Clang, only GCC.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Gold856
Copy link
Contributor Author

Gold856 commented Jan 22, 2025

I added more pragmas to some of the tests so they don't fail when building. I set them up to still print out warnings though so we don't forget.

@dellaert
Copy link
Member

OK. ready to merge?

@Gold856
Copy link
Contributor Author

Gold856 commented Jan 23, 2025

Building all the tests and examples without Boost works on my machine, so I'm ready when you are.

@dellaert dellaert merged commit 105e591 into borglab:develop Jan 23, 2025
35 checks passed
@dellaert
Copy link
Member

Merged! Many thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants