-
Notifications
You must be signed in to change notification settings - Fork 141
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
std::optional serialization conflicts with boost::shared_ptr in Boost 1.84 and 1.85 #319
Comments
Compiles w/o error for me using clang: |
Confirmed in Godbolt: https://godbolt.org/z/8h5Mc3aYe (works with clang and not with gcc). It is strange that is trying to use a type called |
This is the problematic code: https://github.com/boostorg/serialization/blob/develop/include/boost/serialization/shared_ptr_helper.hpp#L45 Here it is a confirmation that this line is problematic and a proposed change by properly declaring U as a template parameter https://godbolt.org/z/jh5T1Tvjs The difference in the two compilers may come from the |
Attempt to solve boostorg#319 , using the technique discussed in the thread
I opened a PR #320 to solve what that I think causes this problem. |
Yep, we found the same problem in our project today. Please fix :) |
Does the following sample work with your fix for you?
I tried your fix, but for me it raises the following issue, but I must say beforehand - I am using 1.78 with some patches backported from more recent versions, so maybe it is my fault:
|
The following replacement of faulty fwd declaration in shared_ptr_helper.hpp works for us, I am not sure if this is correct:
|
We found the same problem in our project, which prevents builds in latest Ubuntu 24.04. |
I'm experiencing a very strange compilation issue when using boost::shared_ptr with the (de)serialization of std::optional.
std::optional serialization support has been added recently in version 1.84.0: https://www.boost.org/doc/libs/1_84_0/boost/serialization/optional.hpp (see also commit 61a2b1207619cedb1f4d3ac1c7193f10ef9334f7)
After a lot of effort I have reduced the problem to a minimal reproducible example, which highlights the issue in both 1.84 and 1.85 versions (earlier versions don't support std::optional serialization).
MRE:
Error (there's lots of text, here's only the error line):
Compilation flags:
g++ f.cpp -std=c++17 -g -O3 -Wall -DNDEBUG -o f -I$BOOST_ROOT -L$BOOST_ROOT/stage/lib -static -lboost_system -lboost_serialization -s
Compiler version:
This example doesn't compile.
If any of the corresponding lines in the code are commented out, there's no error whatsoever.
UPD. It looks like a gcc-specific issue. I have no compilation issues with MSVC Community 2022 (64-bit) Version 17.10.4.
The text was updated successfully, but these errors were encountered: