
On Sat, Nov 16, 2024 at 9:18 PM Ruben Perez
vtable.hpp contains the following piece of code:
auto r = mod.insert(value{argv[1]}, boost::span<value>{reinterpret_cast
(argv + 2), static_caststd::size_t(argc - 2)}, sqlite3_vtab_on_conflict(db));
Where argv is a sqlite3_value **, and sqlite3::value is a wrapper class roughly looking like this:
struct value { // More member functions explicit value(sqlite3_value * value_) noexcept : value_(value_) {} private: sqlite3_value * value_ = nullptr; };
I had the impression that such a cast is UB (although it seems to work and seems to be accepted by ubsan). Could someone with more knowledge about the language point out whether this is allowed or not (and why)
I have a static assert in the code, to make sure this works out. static_assert(sizeof(value) == sizeof(sqlite3_value*), "value must be same as sqlite3_value* pointer"); If the struct is aligned to the pointer it should be fine. But it might technically still be UB, I am not sure either.
Thanks, Ruben.