https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101718
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> --- (In reply to Matt Jacobson from comment #0) > When a method returns a type that the platform ABI says is returned in > memory, the Objective-C frontend (for the NeXT runtime ABIs) emits a call to > `objc_msgSend_stret`; the `_stret` variant of the message dispatcher knows > to look at the *second* argument for `self`, and so on, since the first > argument is the pointer to where the return value will go. > > On some platforms, `_Complex double` is too large to be returned through > registers, so it's returned through memory. can you give me some idea of the platform? it would help with testing at least (assuming that there is a suitable machine on the cfarm). Having said that, there could be some types for which this would fire even on Darwin. > But the Objective-C frontend still insists on using `objc_msgSend`, not > `objc_msgSend_stret`. > > `objc_msgSend` is thoroughly confused when the first argument, which it > expects to be `self`, is actually a pointer to garbage-filled stack. > > I believe this happens because this check: > > ``` > /* If we are returning a struct in memory, and the address > of that memory location is passed as a hidden first > argument, then change which messenger entry point this > expr will call. NB: Note that sender_cast remains > unchanged (it already has a struct return type). */ > if (!targetm.calls.struct_value_rtx (0, 0) > && (TREE_CODE (ret_type) == RECORD_TYPE > || TREE_CODE (ret_type) == UNION_TYPE) > && targetm.calls.return_in_memory (ret_type, 0)) > { > ``` > > limits the use of `stret` to record/union types. Primitive types that are > returned in memory should also be made to use `stret` (the name's meaning > notwithstanding). makes sense, but the fix might be interesting given the "NB: Note that sender_cast remains unchanged (it already has a struct return type)." which would no longer be true for a primitive type.