When the RNA function dispatch system builds a ParameterList, it doesn't currently respect type alignment. This is a fix for this issue described in T97691
I found this issue trying to clear out preexisting warnings from blender to help diagnose issues in another subsystem. It was caught by Xcode's Undefined Behavior Sanitizer, which I expect isn't commonly used by most developers as it is a macOS exclusive IDE. (@Ray Molenkamp (LazyDodo) pointed out that this is a cross-platform tool, and requires the code to be custom compiled to support it, so it isn't purely runtime analysis.)
This is a proof of concept/work-in-progress implementation. It simply adds 0 or more padding bytes to the size of the previous parameter. (ALERT possible memory violation needing fix:) This likely has issues copying from/to off the end of the parameters being padded. While this could be a serious issue, the easy solution is to make the ParameterList aware of the size and padding of elements individually, and should not be a difficult addition to the code.
This is a more polished PR but still will probably benefit from advice from more seasoned Blender developers.
Alternative solutions might include modify the code to work with actual structs for each ParameterList so that the compiler can manage the field alignments, but I suspect that would be a much bigger code change. We could also use std::function<> templates to expose the function arguments differently, but this would likely be even more work. I think the std::function<> is likely the best long term solution using modern C++ semantics, but the purpose of this patch is to fix the issue without additional growing pains.
Aside from the memory violation issue sighted above, I think it's possible that an array parameter could need inter-element padding. This is also a simple addition, but I don't see any of the types currently supported needing it. (This would be required if a type's size is smaller than, or not a multiple of its alignment.) (I was unaware that the language hides this complexity from developers, and because we mostly only pass basic types here, the type size and alignment are usually the same.)
No external change is proposed, so no mockup is included.