cereal
cereal copied to clipboard
GCC 13.2 build error: possible dangling reference to a temporary
GCC 13.2 finds a possible dangling reference in include/cereal/details/polymorphic_impl.hpp
line 204, 218, 231:
//.... error: possibly dangling reference to a temporary [-Werror=dangling-reference]
auto const &mapping = lookup( baseInfo, typeid(Derived), [&](){ UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION(save) } );
^~~~~~~
I also ran into this issue.
After some investigation this now looks it might be a compiler bug i.e. a false positive.
The return time of the lookup function is std::vector<PolymorphicCaster const *> const &
and the value is a reference to a vector stored in the map StaticObject<PolymorphicCasters>::getInstance().map
which is not temporary.
There are a couple of other projects that reported similar compiler regressions on GCC 13, for example 107532.
After updating from GCC 13.2 to 14.1, the false-positive warning is indeed gone.
This issue can probably be closed as this confirms that this is a compiler regression?