Wyizolowałem problem do prostego projektu
https://github.com/mariuszmaximus/4p_362705
bug.cpp
#include "bug.h"
#include <iostream> // std::cout
void Config::bug()
{
nlohmann::json j2;
j2["name"] = "Niels"; // to powoduje ze projekt się nie kompiluje
std::cout << j2.dump() << '\n';
}
Plik "bug.cpp" nie che sie zbudować w Relesae w msys2 (gcc 12.1)
[proc] Executing command: c:\bin\cmake-3.23.2-windows-x86_64\bin\cmake.EXE --build c:/Users/mariusz/Desktop/gity/json_bug/build --config Release --target all --
[build] [1/2 50% :: 2.092] C:\msys64\mingw64\bin\g++.exe -IC:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include -O3 -DNDEBUG -Wall -Wextra -Werror -fPIC -Werror=return-type -Wno-unknown-pragmas -MD -MT CMakeFiles/json_bug.dir/bug.cpp.obj -MF CMakeFiles\json_bug.dir\bug.cpp.obj.d -o CMakeFiles/json_bug.dir/bug.cpp.obj -c C:/Users/mariusz/Desktop/gity/json_bug/bug.cpp
[build] FAILED: CMakeFiles/json_bug.dir/bug.cpp.obj
[build] C:\msys64\mingw64\bin\g++.exe -IC:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include -O3 -DNDEBUG -Wall -Wextra -Werror -fPIC -Werror=return-type -Wno-unknown-pragmas -MD -MT CMakeFiles/json_bug.dir/bug.cpp.obj -MF CMakeFiles\json_bug.dir\bug.cpp.obj.d -o CMakeFiles/json_bug.dir/bug.cpp.obj -c C:/Users/mariusz/Desktop/gity/json_bug/bug.cpp
[build] In file included from C:/msys64/mingw64/include/c++/12.1.0/map:60,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/detail/conversions/from_json.hpp:15,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/adl_serializer.hpp:14,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:35,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/bug.h:4,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/bug.cpp:1:
[build] In member function 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::begin() [with _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> >; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> > >; _Compare = std::less<void>; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> > >]',
[build] inlined from 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::begin() [with _Key = std::__cxx11::basic_string<char>; _Tp = nlohmann::json_v3_11_1_diag::basic_json<>; _Compare = std::less<void>; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> > >]' at C:/msys64/mingw64/include/c++/12.1.0/bits/stl_map.h:367:26,
[build] inlined from 'void nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::set_parents() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_v3_11_1_diag::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:709:17,
[build] inlined from 'void nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::set_parents() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_v3_11_1_diag::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:693:10,
[build] inlined from 'nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::basic_json(CompatibleType&&) [with CompatibleType = const char (&)[6]; U = char [6]; typename std::enable_if<((! nlohmann::json_v3_11_1_diag::detail::is_basic_json<U>::value) && nlohmann::json_v3_11_1_diag::detail::is_compatible_type<nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>, U>::value), int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_v3_11_1_diag::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:830:20,
[build] inlined from 'void Config::bug()' at C:/Users/mariusz/Desktop/gity/json_bug/bug.cpp:7:18:
[build] C:/msys64/mingw64/include/c++/12.1.0/bits/stl_tree.h:996:16: error: array subscript 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> > >, std::less<void>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::json_v3_11_1_diag::basic_json<> > > >[0]' is partly outside array bounds of 'unsigned char [32]' [-Werror=array-bounds]
[build] 996 | { return iterator(this->_M_impl._M_header._M_left); }
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from C:/msys64/mingw64/include/c++/12.1.0/x86_64-w64-mingw32/bits/c++allocator.h:33,
[build] from C:/msys64/mingw64/include/c++/12.1.0/bits/allocator.h:46,
[build] from C:/msys64/mingw64/include/c++/12.1.0/unordered_map:40,
[build] from C:/msys64/mingw64/include/c++/12.1.0/functional:61,
[build] from C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:23:
[build] In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::__cxx11::basic_string<char>]',
[build] inlined from 'static _Tp* std::allocator_traits<std::allocator<_Tp1> >::allocate(allocator_type&, size_type) [with _Tp = std::__cxx11::basic_string<char>]' at C:/msys64/mingw64/include/c++/12.1.0/bits/alloc_traits.h:464:28,
[build] inlined from 'static T* nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::create(Args&& ...) [with T = std::__cxx11::basic_string<char>; Args = {const char (&)[6]}; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_v3_11_1_diag::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:387:47,
[build] inlined from 'static void nlohmann::json_v3_11_1_diag::detail::external_constructor<nlohmann::json_v3_11_1_diag::detail::value_t::string>::construct(BasicJsonType&, const CompatibleStringType&) [with BasicJsonType = nlohmann::json_v3_11_1_diag::basic_json<>; CompatibleStringType = char [6]; typename std::enable_if<(! std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value), int>::type <anonymous> = 0]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/detail/conversions/to_json.hpp:85:79,
[build] inlined from 'void nlohmann::json_v3_11_1_diag::detail::to_json(BasicJsonType&, const CompatibleString&) [with BasicJsonType = nlohmann::json_v3_11_1_diag::basic_json<>; CompatibleString = char [6]; typename std::enable_if<std::is_constructible<typename BasicJsonType::string_t, Key>::value, int>::type <anonymous> = 0]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/detail/conversions/to_json.hpp:281:53,
[build] inlined from 'decltype ((nlohmann::json_v3_11_1_diag::detail::to_json(j, forward<T>(val)), void())) nlohmann::json_v3_11_1_diag::detail::to_json_fn::operator()(BasicJsonType&, T&&) const [with BasicJsonType = nlohmann::json_v3_11_1_diag::basic_json<>; T = const char (&)[6]]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/detail/conversions/to_json.hpp:422:23,
[build] inlined from 'static decltype ((nlohmann::json_v3_11_1_diag::to_json(j, forward<TargetType>(val)), void())) nlohmann::json_v3_11_1_diag::adl_serializer<T, SFINAE>::to_json(BasicJsonType&, TargetType&&) [with BasicJsonType = nlohmann::json_v3_11_1_diag::basic_json<>; TargetType = const char (&)[6]; ValueType = char [6]; <template-parameter-1-2> = void]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/adl_serializer.hpp:51:28,
[build] inlined from 'nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::basic_json(CompatibleType&&) [with CompatibleType = const char (&)[6]; U = char [6]; typename std::enable_if<((! nlohmann::json_v3_11_1_diag::detail::is_basic_json<U>::value) && nlohmann::json_v3_11_1_diag::detail::is_compatible_type<nlohmann::json_v3_11_1_diag::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>, U>::value), int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::json_v3_11_1_diag::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/json_bug/build/_deps/json-src/include/nlohmann/json.hpp:829:35,
[build] inlined from 'void Config::bug()' at C:/Users/mariusz/Desktop/gity/json_bug/bug.cpp:7:18:
[build] C:/msys64/mingw64/include/c++/12.1.0/bits/new_allocator.h:137:55: note: object of size 32 allocated by 'operator new'
[build] 137 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
[build] | ^
[build] cc1plus.exe: all warnings being treated as errors
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1
Tam gdzie używam nlohmann::json nie ma Qt ten pierwsze bledy byly akurat z main gdzie jest uzyte Qt ale raczej nie ma zwiazku (chyba) bo na git uzyskalem ten sam problem bez QT