SDCC doesn't support functions that return struct yet. But it does not give an error on calling such a function either.
However, the generated code is incorrect. It assumes that the function returns a pointer to a struct. However, this can't work, since the lifetime of any object in the callee that pointer might point to has ended.
Instead, this should be handled like functions returning long long are handled in at least stm8 and z80-related backends: The caller passes a pointer as extra hidden parameter, so the callee can write the result there.
Philipp
The main problem here is not the code generation for the call itself (that was an easy fix, for stm8 done in [r10680]), but the iCode reaching the backend. Just after the call I already see wrong iCode treating the struct as pointer to struct.
Philipp
Last edit: Philipp Klaus Krause 2018-11-29
struct / union return support is now working for most ports. For the exceptions, there is an error message.