[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: Support non-standard extension (call via casted function pointer)



On 26.01.2016 08:25, Jeff Law wrote:
> I believe if they make the return type a pointer type, then the m68k
> backend ought to return the value in a0 and d0 to make broken code
> like this work.  It may also be the case that we're not doing this
> properly for indirect calls from a quick scan of m68k_function_arg.
It works properly on the callee side: A function declared to return a
pointer returns in both a0 and d0.
On the caller side, a the result of a function returning a pointer is
expected in a0 (obviously correct for the SVR4/m68k ABI), even if a
"pointer-to-function returning int" is used to call that function.
(which is obviously undefined behaviour. See the linked ghc problem
report for chapter and verse). My patch makes ghc retrieve the value
from d0 instead of a0, if the actually returned value in the
call-expression has a non-pointer type, even if the called function is
known and declared as returning a pointer.

Regards,
  Michael Karcher


Reply to: