danielaparker / jsoncons

A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
https://danielaparker.github.io/jsoncons
Other
699 stars 158 forks source link

GCC 13 build fails due to multiple: warning: 'template<long unsigned int _Len, long unsigned int _Align> struct std::aligned_storage' is deprecated [-Wdeprecated-declarations] #418

Closed eitlane closed 1 year ago

eitlane commented 1 year ago

Hi all,

Compiling jsoncons 0.170.0 with gcc 13 (x86_64, linux, build from 12 March commit: f23dc726875c26f2c38dfded453aa9beba0b9be9) build fails with multiple errors like:

/include/jsoncons/detail/string_wrapper.hpp:101:31: warning: 'template<long unsigned int _Len, long unsigned int _Align> struct std::aligned_storage' is deprecated [-Wdeprecated-declarations]
         typedef typename std::aligned_storage<sizeof(storage_t), alignof(storage_t)>::type json_storage_kind;
                                         ^~~~~~~~~~~~~~~
 In file included from /include/c++/13.0.1/bits/char_traits.h:50,
                  from /include/c++/13.0.1/string:42,
                  from /jsoncons-0.170.0/include/jsoncons/basic_json.hpp:11:
/include/c++/13.0.1/type_traits:2099:5: note: declared here
         aligned_storage
         ^~~~~~~~~~~~~~~

Once I removed -Werror from the cmake file, the project compiled successfully.

Thanks V

danielaparker commented 1 year ago

Thanks for reporting this. Yes, C++23 is deprecating std::aligned_storage, which jsoncons uses for a structure for storing string data, because std::aligned_* suffers from many poor API design decisions. We'll be investigating a replacement for the next release.

danielaparker commented 1 year ago

Fixed on master.

eitlane commented 1 year ago

Hello @danielaparker

Thanks a lot for the fast response. I wish everybody responds as fast as you :)

I applied the patch on my side but it still fails (much further though - 76% instead of 6%)

Here is the error:

[ 76%] Building CXX object test/CMakeFiles/unit_tests.dir/corelib/src/json_storage_tests.cpp.o
In file included from jsoncons-0.170.0/test/corelib/src/json_reader_tests.cpp:7:
jsoncons-0.170.0/test/corelib/src/freelist_allocator.hpp:20:23: error: 'template<long unsigned int _Len, long unsigned int _Align> struct std::aligned_storage' is deprecated [-Werror=deprecated-declarations]
   20 |         typename std::aligned_storage<sizeof(T), alignof(T)>::type storage;
      |                       ^~~~~~~~~~~~~~~
In file included from  include/c++/13.0.1/bits/char_traits.h:50,
                 from  include/c++/13.0.1/string:42,
                 from  jsoncons-0.170.0/include/jsoncons/basic_json.hpp:11,
                 from  jsoncons-0.170.0/include/jsoncons/json.hpp:10,
                 from  jsoncons-0.170.0/test/corelib/src/json_reader_tests.cpp:4:
 include/c++/13.0.1/type_traits:2099:5: note: declared here
 2099 |     aligned_storage
      |     ^~~~~~~~~~~~~~~

Am I doing something wrong ?

Thanks, V

danielaparker commented 1 year ago

You're right, I fixed the one in the jsoncons library, but there were a couple of additional ones in the test code, and one in the third party catch.hpp header. I updated to the latest catch.hpp, which fixed its issue, and fixed the rest. Fixes are on master.

eitlane commented 1 year ago

After applying the patches the build is green. :) Thanks for the reactive support V