Jak zinterpretować błąd?

0

Używam wersji Debug zazwyczaj ale przelaczylem budowanie na Relese i zauważyłem dziwny problem:

Jak w projekcie mam spełniony taki warunki:

  1. włączone makro JSON_DIAGNOSTICS (przed #include <nlohmann/json.hpp>)
  2. używam <nlohmann/json.hpp>
  3. flagi -Wall -Wextra -Werror
  4. add a string that is stored as std::string nlohmann::json j2; j2["name"] = "Niels";
  5. gcc w wersji 12 na Windows , bo na gcc 10 to nie obserwowałem tego problemu
  6. Buduje Relase
 nlohmann::json j2; 
 j2["name"] = "Niels"; // to powoduje ze projekt się nie kompiluje

Projekt sie nie kompiluje w wersji Release
błąd dość dziwny

[build] C:/msys64/mingw64/include/c++/12.1.0/bits/stl_tree.h16: error: array subscript 'std::_Rb_tree<std::basic_string<char>, std::pair<const std::basic_string<char>, nlohmann::basic_json<> >, std::_Select1st<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > >, std::less<void>, std::allocator<std::pair<const std::basic_string<char>, nlohmann::basic_json<> > > >[0]' is partly outside array bounds of 'unsigned char [32]' [-Werror=array-bounds]

rozwiniecie błedu
https://gist.github.com/mariuszmaximus/8b75697ecd9bc4f63348898e6b061f2c

moge zablokować "array-bounds" np. tak
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>
#pragma GCC diagnostic pop

Ale to tylko pudruje problem bez wyjaśniania dlaczego tak się dzieje !

Nie jestem w stanie powtórzyc problemu poza moim projektem wiec na pewno problem jest po mojej stronie tylko że wszystkie uwagi kompilatora są poza moim kodem w takim wypadku zastanawiam się jak to naprawić

0

j2[string("name")] = "Niels"; ?

1

Nie mogę zreprodukować: https://godbolt.org/z/qrndnEn6a

0

Skopiowane z linka aby było widać bezpośrednio w pytaniu:

[build] In file included from C:/msys64/mingw64/include/c++/12.1.0/map:60,
[build]                  from C:/msys64/mingw64/include/QtCore/qmetatype.h:56,
[build]                  from C:/msys64/mingw64/include/QtCore/qobject.h:54,
[build]                  from C:/msys64/mingw64/include/QtCore/qcoreapplication.h:46,
[build]                  from C:/msys64/mingw64/include/QtWidgets/qapplication.h:44,
[build]                  from C:/msys64/mingw64/include/QtWidgets/QApplication:1,
[build]                  from C:/Users/m/Desktop/gity/_128/us128/src/app_u128/source/main.cpp:21:
[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::basic_json<> >; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, nlohmann::basic_json<> > >; _Compare = std::less<void>; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::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::basic_json<>; _Compare = std::less<void>; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::basic_json<> > >]' at C:/msys64/mingw64/include/c++/12.1.0/bits/stl_map.h:367:26,
[build]     inlined from 'void nlohmann::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::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:17877:17,
[build]     inlined from 'void nlohmann::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::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:17861:10,
[build]     inlined from 'nlohmann::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::detail::is_basic_json<U>::value) && nlohmann::detail::is_compatible_type<nlohmann::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::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:17998:20,
[build]     inlined from 'void test_MB()' at C:/Users/m/Desktop/gity/_128/us128/src/app_u128/source/main.cpp:669:15:
[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::basic_json<> >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, nlohmann::basic_json<> > >, std::less<void>, std::allocator<std::pair<const std::__cxx11::basic_string<char>, nlohmann::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/string:41,
[build]                  from C:/Users/m/Desktop/gity/_128/us128/src/us_base/src/sysutils.h:12,
[build]                  from C:/Users/m/Desktop/gity/_128/us128/src/app_u128/source/main.cpp:12:
[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<_CharT> >::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::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::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:17555:47,
[build]     inlined from 'static void nlohmann::detail::external_constructor<nlohmann::detail::value_t::string>::construct(BasicJsonType&, const CompatibleStringType&) [with BasicJsonType = nlohmann::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/_128/us128/3rdparty/nlohmann/json.hpp:4573:79,
[build]     inlined from 'void nlohmann::detail::to_json(BasicJsonType&, const CompatibleString&) [with BasicJsonType = nlohmann::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/_128/us128/3rdparty/nlohmann/json.hpp:4762:53,
[build]     inlined from 'decltype ((nlohmann::detail::to_json(j, forward<T>(val)), void())) nlohmann::detail::to_json_fn::operator()(BasicJsonType&, T&&) const [with BasicJsonType = nlohmann::basic_json<>; T = const char (&)[6]]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:4901:23,
[build]     inlined from 'static decltype ((nlohmann::{anonymous}::to_json(j, forward<TargetType>(val)), void())) nlohmann::adl_serializer<T, SFINAE>::to_json(BasicJsonType&, TargetType&&) [with BasicJsonType = nlohmann::basic_json<>; TargetType = const char (&)[6]; ValueType = char [6]; <template-parameter-1-2> = void]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:4954:28,
[build]     inlined from 'nlohmann::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::detail::is_basic_json<U>::value) && nlohmann::detail::is_compatible_type<nlohmann::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::adl_serializer; BinaryType = std::vector<unsigned char>]' at C:/Users/mariusz/Desktop/gity/_128/us128/3rdparty/nlohmann/json.hpp:17997:35,
[build]     inlined from 'void test_MB()' at C:/Users/m/Desktop/gity/_128/us128/src/app_u128/source/main.cpp:669:15:
[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
2

Swoja drogą skoro używasz Qt to po co ci nlohmann::json?
Qt ma wbudowaną obsługę JSon i używa typów specyficznych dla Qt (QString). Użwając nlohmann::json zmuszasz się do dodatkowej konwersji pomiędzy std::string a QString.
Tak się nawet zastanawiam, czy nie ma jakiegoś konfliktu symboli między nlohmann::json a QJsonDocument i pokrewnymi.

0

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

0

Sprawdziłem ten projekt https://github.com/mariuszmaximus/4p_362705 na starszych gcc na Windows
gcc 10.3.0 i nie ma żadnych problemów
gcc 11.3.0 i nie ma żadnych problemów
gcc 12.1.0 nie kompiluje się bug.cpp

A było nie aktualizować jak działa :D

2

Wydaje się, że głowny problem to:

[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); }

Albo błąd jest w kodzie albo nowszy kompilator ma buga.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104657
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

Możesz to próbować ominąć dodając flagę do kompilatora: -Wno-error=array-bounds

3

Wygooglałem i wyszedł bug już zaraportowany w standardowej bibliotece.

0

Tak z ciekawości , co wpisałeś do wyszukiwarki ?

1 użytkowników online, w tym zalogowanych: 0, gości: 1