The solution was to coerce GCC into not using its own inline memcpy without affecting other inlining. Turns out all you have to do is make the size argument a variable rather than a constant. So I changed lines like this:
memcpy(to, from, 8);
to this:
int sz = 8;
memcpy(to, from, sz);
I'll send this off to Matt tonight, and I should also port it to the main SQLite codebase. This took way too long to figure out...
gcc buggy? (Score:2)
Given that
memcpyis prototypedvoid *memcpy(void *dst, const void *src, size_t len);is sqlite actually at fault here? Or is the gcc optimisation buggy? I'm not a sufficiently good C standards guru to know this, even if I looked at precisely what the code is doing. (Which I confess, I haven't)Re:gcc buggy? (Score:1)
On the SQLite side, arrays of char * were being casted to structs and then memcpy'd. With this layout, every other array element was misaligned on Solaris, but it was fine on x86. Very, very bad. D. Richard Hipp (author of SQLite) and I actually worked out a better solution than m