Open ottojo opened 5 months ago
Seems like GCC fixed a bug it had because we had a conditional compilation step in gtsam/base/serialization.h
. The fix should be simple: check if the GCC version is >=7
and <13
for that block. Can you make a PR? I can help land it.
I think this relates to the workaround in https://github.com/borglab/gtsam/blob/develop/gtsam/base/std_optional_serialization.h#L30 rather than serialization.h
, since it seems to correlate with including <boost/serialization/shared_ptr.hpp>
, as mentioned in the comment there.
From what i can tell, GCC still exhibits the bug described in the comment (trying to instantiate objects of type T<boost::serialization::U>
when boost::serialization::U
doesn't exist).
But GCC<13 accepted the incomplete type U in the specializations of the form
namespace boost { namespace serialization { struct U; } }
namespace std { template<> struct is_trivially_default_constructible<boost::serialization::U> : std::false_type {}; }
which GCC 13 does not anymore. It seems gcc rejects using incomplete types here since version 13, and clang since version 16, so perhaps it was erroneously accepted before.
The issue seems to disappear if U
is fully declared
- namespace boost { namespace serialization { struct U; } }
+ namespace boost { namespace serialization { struct U{}; } }
but I'm unsure if this has any unintended side effects.
Interestingly, both GCC 12.3 and 13.2.1 don't actually seem to require the type traits, only the declaration/definition of U
, but i haven't tested any older GCC versions...
That's a great catch and analysis. I think you've found the core of the problem and described it very nicely (with a potential fix).
I agree that it is uncertain what a full declaration of U
will end up doing. I will need to look into this extensively, but I unfortunately don't have the time this week. I can get back to this after the 29th of March if that works?
No rush at all, thank you for looking into the issue! I'm not depending on using GCC13 anytime soon, it just happened to be the default on my system.
Description
testStdOptionalSerialization.cpp
fails to build witherror: invalid use of incomplete type ‘struct boost::serialization::U’
.Steps to reproduce
Build failure:
CMake configuration
``` CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argumentExpected behavior
Successful build
Environment
6.7.10-1-MANJARO
13.2.1 20230801
1.83