qicosmos / iguana

universal serialization engine
Apache License 2.0
1.12k stars 228 forks source link

xml test fail:Uncaught (in promise) RuntimeError: memory access out of bounds #192

Open sonygod opened 1 year ago

sonygod commented 1 year ago

platform: emscripten wasm

void test_xml()
{
    person p = {"admin", 20};
    iguana::string_stream ss;
    iguana::to_xml(ss, p);
    std::cout << ss << std::endl;

    ss.clear();
    two t = {"test", {2}, 4};
    iguana::to_xml(ss, t);

    std::cout << ss << std::endl;

    two t1;
    iguana::from_xml(t1, ss.data());//
    std::cout << t1.age << "\n";

}

iguana::from_xml(t1, ss.data());//will throw Uncaught (in promise) RuntimeError: memory access out of bounds

bbbgan commented 1 year ago

Is this the old version? iguana::xml has been refactored recently. Can you give it a try? However, it is based on C++20, The support for C++17 is In the plan

bbbgan commented 1 year ago

First of all, "../frozen/string.h" should be "frozen/string.h", just pay attention to the path. Secondly, there is a conflicting redefinition between YAML、JSON and XML, and it has not been resolved yet.

------------------ 原始邮件 ------------------ 发件人: "Mr @.>; 发送时间: 2023年7月12日(星期三) 下午5:57 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [qicosmos/iguana] xml test fail:Uncaught (in promise) RuntimeError: memory access out of bounds (Issue #192)

afer update to latest version ,got some other error: [ 33%] Building CXX object CMakeFiles/CPPHX.dir/test/TestCase.cpp.o In file included from /home/rock/tools/CppHx/test/TestCase.cpp:43: In file included from /home/rock/tools/CppHx/Public/Json.h:4: In file included from /home/rock/tools/CppHx/Public/iguana/json_reader.hpp:5: In file included from /home/rock/tools/CppHx/Public/iguana/json_util.hpp:7: /home/rock/tools/CppHx/Public/iguana/reflection.hpp:20:10: error: '../frozen/string.h' file not found, did you mean 'frozen/string.h'? 20 | #include "../frozen/string.h" | ^~~~~~~~ | "frozen/string.h" In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:19:9: error: redefinition of 'char_t' 19 | concept char_t = std::same_as < std::decay_t<T>, | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:22:9: note: previous definition is here 22 | concept char_t = std::same_as < std::decay_t<T>, | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:25:9: error: redefinition of 'bool_t' 25 | concept bool_t = std::same_as < std::decay_t<T>, | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:28:9: note: previous definition is here 28 | concept bool_t = std::same_as < std::decay_t<T>, | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:29:9: error: redefinition of 'int_t' 29 | concept int_t = | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:32:9: note: previous definition is here 32 | concept int_t = | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:33:9: error: redefinition of 'float_t' 33 | concept float_t = std::floating_point<std::decay_t<T>>; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:36:9: note: previous definition is here 36 | concept float_t = std::floating_point<std::decay_t<T>>; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:36:9: error: redefinition of 'num_t' 36 | concept num_t = std::floating_point<std::decay_t<T>> || int_t<T>; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:39:9: note: previous definition is here 39 | concept num_t = std::floating_point<std::decay_t<T>> || int_t<T>; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:39:9: error: redefinition of 'enum_t' 39 | concept enum_t = std::is_enum_v<std::decay_t<T>>; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:42:9: note: previous definition is here 42 | concept enum_t = std::is_enum_v<std::decay_t<T>>; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:41:45: error: redefinition of 'is_basic_string_view' 41 | template <typename T> constexpr inline bool is_basic_string_view = false; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:47:45: note: previous definition is here 47 | template <typename T> constexpr inline bool is_basic_string_view = false; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:44:23: error: redefinition of 'is_basic_string_view<std::basic_string_view<T>>' 44 | constexpr inline bool is_basic_string_view<std::basic_string_view<T>> = true; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:50:23: note: previous definition is here 50 | constexpr inline bool is_basic_string_view<std::basic_string_view<T>> = true; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:47:9: error: redefinition of 'str_view_t' 47 | concept str_view_t = is_basic_string_view<std::remove_reference_t<T>>; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:96:9: note: previous definition is here 96 | concept str_view_t = is_basic_string_view<std::remove_reference_t<T>>; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:50:9: error: redefinition of concept 'str_t' with different template parameters or requirements 50 | concept str_t = | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:100:9: note: previous definition is here 100 | concept str_t = | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:57:9: error: redefinition of 'tuple_t' 57 | concept tuple_t = is_tuple<std::remove_cvref_t<T>>::value; | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:143:9: note: previous definition is here 143 | concept tuple_t = is_tuple<std::remove_cvref_t<T>>::value; | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:60:9: error: redefinition of 'sequence_container_t' 60 | concept sequence_container_t = | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:139:9: note: previous definition is here 139 | concept sequence_container_t = | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:64:9: error: redefinition of 'unique_ptr_t' 64 | concept unique_ptr_t = requires(Type ptr) { | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:149:9: note: previous definition is here 149 | concept unique_ptr_t = requires(Type ptr) { | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:79:9: error: redefinition of 'container' 79 | concept container = requires(Type container) { | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:69:9: note: previous definition is here 69 | concept container = requires(Type container) { | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:86:9: error: redefinition of 'map_container' 86 | concept map_container = container<Type> && requires(Type container) { | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:77:9: note: previous definition is here 77 | concept map_container = container<Type> && requires(Type container) { | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:95:9: error: redefinition of 'c_array' 95 | concept c_array = std::is_array_v<std::remove_cvref_t<T>> && | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:82:9: note: previous definition is here 82 | concept c_array = std::is_array_v<std::remove_cvref_t<T>> && | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:100:9: error: redefinition of 'array' 100 | concept array = requires(Type arr) { | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:87:9: note: previous definition is here 87 | concept array = requires(Type arr) { | ^ In file included from /home/rock/tools/CppHx/test/TestCase.cpp:47: In file included from /home/rock/tools/CppHx/Public/iguana/xml_reader.hpp:4: /home/rock/tools/CppHx/Public/iguana/xml_util.hpp:106:9: error: redefinition of 'tuple' 106 | concept tuple = !array<Type> && requires(Type tuple) { | ^ /home/rock/tools/CppHx/Public/iguana/json_util.hpp:105:9: note: previous definition is here 105 | concept tuple = !array<Type> && requires(Type tuple) { | ^ fatal error: too many errors emitted, stopping now [-ferror-limit=]

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

bbbgan commented 1 year ago

I am planing to resolve these conflicts while supporting 17, and if necessary, you can also resolve these conflicts yourself. If you want me to solve it, it's also my pleasure