On Thu, Feb 21, 2013 at 7:58 AM, Johannes Pfau <johannesp...@gmail.com> wrote: > > the gdc D compiler currently doesn't implement "non-POD" types. As in C++ > those > types can have copy constructors or destructors and should be kept in memory. > Right now I just set TREE_ADDRESSABLE on the RECORD_TYPE tree and it's mostly > working. Some test cases fail though if optimization / inlining is enabled: > > D code like this: > ------ > Appender appender() { return Appender(""); } > > void main() { > Appender w = appender(); > auto x = &w; > } > ------ > where Appender is a non-POD type causes an assertion failure in > declare_return_variable: "gcc_assert (!TREE_ADDRESSABLE (callee_type));" > > There's a comment saying "All types requiring non-trivial constructors should > have been handled." but where and how? The problem only occurs if the address > of > w is taken, as this will mark w as addressable. Then > gimple_call_return_slot_opt_p test in expand_call_inline fails and return_slot > is not set. If the address of w is not taken the return_slot is used and > everything works fine.
I don't know exactly what is going wrong. But I can tell you that if a function returns a TREE_ADDRESSABLE type, that should be handled by passing in an invisible first parameter that is a pointer to the area on the stack where the function should write the return value. Ian