On Sunday 23 November 2008 03:15:36 pm Francois Gouget wrote:
To quote Ken Thomases who did the research on this issue with Alexandre:
This is motivated by a gcc bug that we've encountered on the Mac. On the Mac, WINAPI (and other declspecs) include the force_align_arg_pointer attribute. With -O2 optimization (actually -funit-at-a-time, implied by -O2) the compiler may change the calling convention used by non-exported functions to take arguments via registers rather than on the stack. The prologue generated for force_align_arg_pointer clobbers one of those registers (and hence one of the arguments).
Alexandre's preferred solution is to find and eliminate such cases. Even if/when the compiler bug is fixed, those functions should still not have the extraneous declspec.
Out of curiousity, then, does this affect static functions that are used for COM objects? It's typical for those to be marked as static, their address put into a (possibly static) vtable struct, which is then used as a field for an allocated struct passed to the user.
Chris Robinson wrote: [...]
Out of curiousity, then, does this affect static functions that are used for COM objects? It's typical for those to be marked as static, their address put into a (possibly static) vtable struct, which is then used as a field for an allocated struct passed to the user.
Functions used for COM objects are not impacted. The compiler sees that their address is taken and thus that they may be called from outside the current compilation unit. It then knows it's not allowed to change their calling convention and the bug is averted.