USCiLab / cereal

A C++11 library for serialization
BSD 3-Clause "New" or "Revised" License
4.25k stars 767 forks source link

Macos Build error: cannot bind lvalue of type unsigned long long to value of unrelated type unsigned long #804

Closed inakleinbottle closed 1 year ago

inakleinbottle commented 1 year ago

There appears to be an error in the the internals on MacOs when deserializing a size tag from JSON (and possibly other archive types) on MacOS.

Here is my code (I've unpacked some macros for clarity):

    ::cereal::size_type count;
    archive(::cereal::make_size_tag(count)); // RPY_SERIAL_SERIALIZE_SIZE(count)

    indeterminate_type id(0, 0);
    deg_t degree;
    for (size_t i = 0; i < count; ++i) {
        archive(::cereal::make_map_item(id, degree));
        value[id] = degree;
    }

This compiles just fine on Linux x86_64, but fails on MacOS with the following error:

 /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DRPY_BUILDING_LIBRARY=1 -I/Users/runner/work/RoughPy/RoughPy/scalars/include/roughpy/scalars -I/Users/runner/work/RoughPy/RoughPy/scalars/src -I/Users/runner/work/RoughPy/RoughPy/scalars/include -I/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/scalars -I/Users/runner/work/RoughPy/RoughPy/platform/include -I/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/platform -I/Users/runner/work/RoughPy/RoughPy/external/libalgebra_lite/include -I/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/external/libalgebra_lite -I/Users/runner/work/RoughPy/RoughPy/core/include -I/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/core -isystem /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include -isystem /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/eigen3 -isystem /usr/local/Cellar/gmp/6.2.1_1/include -O3 -DNDEBUG -std=gnu++17 -arch x86_64 -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.0.0 -fPIC -fvisibility-inlines-hidden -MD -MT scalars/CMakeFiles/RoughPy_Scalars.dir/src/scalar_serialization.cpp.o -MF scalars/CMakeFiles/RoughPy_Scalars.dir/src/scalar_serialization.cpp.o.d -o scalars/CMakeFiles/RoughPy_Scalars.dir/src/scalar_serialization.cpp.o -c /Users/runner/work/RoughPy/RoughPy/scalars/src/scalar_serialization.cpp
    In file included from /Users/runner/work/RoughPy/RoughPy/scalars/src/scalar_serialization.cpp:32:
    In file included from /Users/runner/work/RoughPy/RoughPy/platform/include/roughpy/platform/archives.h:33:
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/archives/json.hpp:1013:18: error: non-const lvalue reference to type 'cereal::size_type' (aka 'unsigned long long') cannot bind to a value of unrelated type 'unsigned long'
        ar.loadSize( st.size );
                     ^~~~~~~
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/cereal.hpp:941:9: note: in instantiation of function template specialization 'cereal::load<unsigned long &>' requested here
            CEREAL_LOAD_FUNCTION_NAME(*self, t);
            ^
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/macros.hpp:85:35: note: expanded from macro 'CEREAL_LOAD_FUNCTION_NAME'
    #define CEREAL_LOAD_FUNCTION_NAME load
                                      ^
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/cereal.hpp:853:15: note: in instantiation of function template specialization 'cereal::InputArchive<cereal::JSONInputArchive, 0>::processImpl<cereal::SizeTag<unsigned long &>, 0>' requested here
            self->processImpl( head );
                  ^
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/cereal.hpp:730:9: note: in instantiation of function template specialization 'cereal::InputArchive<cereal::JSONInputArchive, 0>::process<cereal::SizeTag<unsigned long &>>' requested here
            process( std::forward<Types>( args )... );
            ^
    /Users/runner/work/RoughPy/RoughPy/scalars/include/roughpy/scalars/serialization.h:316:5: note: in instantiation of function template specialization 'cereal::InputArchive<cereal::JSONInputArchive, 0>::operator()<cereal::SizeTag<unsigned long &>>' requested here
        RPY_SERIAL_SERIALIZE_SIZE(count);
        ^
    /Users/runner/work/RoughPy/RoughPy/platform/include/roughpy/platform/serialization.h:73:40: note: expanded from macro 'RPY_SERIAL_SERIALIZE_SIZE'
    #  define RPY_SERIAL_SERIALIZE_SIZE(S) archive(::cereal::make_size_tag(S))
                                           ^
    /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/tmpqi_vgsy8/build/vcpkg_installed/x64-osx/include/cereal/archives/json.hpp:726:33: note: passing argument to parameter 'size' here
          void loadSize(size_type & size)
                                    ^
    1 error generated.

Please note this is running in my CI, so I cannot extract any additional log information to provide information

The version of Cereal here is 1.3.2.

inakleinbottle commented 1 year ago

I just noticed that the line reference is not quite the same, and the issue actually occurs on a similar line that I hadn't changed. Closing issue.