This can be seen in the tests/runtime/lists example, in function wasi_http_headers_roundtrip.
Here the C++ result vector storage is also used to lower the elements. These types may or may not have the same size and might disagree on layout. For sure in-depth copying and overwriting the elements in place is not a good idea. The lowered result should be allocated before the copy and the lifted result array freed after the copy. I only found this because my compiler had a different idea of the C++ type layout.
This error is subtle and doesn't show up in the test.
This can be seen in the
tests/runtime/listsexample, in functionwasi_http_headers_roundtrip.Here the C++ result vector storage is also used to lower the elements. These types may or may not have the same size and might disagree on layout. For sure in-depth copying and overwriting the elements in place is not a good idea. The lowered result should be allocated before the copy and the lifted result array freed after the copy. I only found this because my compiler had a different idea of the C++ type layout.
This error is subtle and doesn't show up in the test.