Lots of undefined behavior in extensions/gggl.c
Submitted by Martin Husemann
Link to original bug (#795726)
Description
Created attachment 371584 (mostly) mechanical transformation to use memcpy() to access data with unclear alignement
The conversion functions in gggl.c assume they can cast pointers to unrelated types arbitrarily, both for lhs and rhs.
While this accidentally works on x86 and newer arm, it causes bus errors on most other RISC cpus. From a C standard point of view this all is undefined behavior.
Easy work around: use memcpy() and leave all optimizations to the compiler - which will usually understand the target restrictions and create the same code on x86.
I ran into this because the Gimp build on sparc64 crashed for me (so it is not a theoretical problem but actually prevents building of configurations that previously worked fine).
Side note: the attached patch should be carefully reviewed, this kind of mostly mechanical transforms always end up with errors in my experience.
Patch 371584, "(mostly) mechanical transformation to use memcpy() to access data with unclear alignement":
patch