This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: TREE_ADDRESSABLE types cause ICE in declare_return_variable
- From: Ian Lance Taylor <iant at google dot com>
- To: Johannes Pfau <johannespfau at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 21 Feb 2013 08:51:56 -0800
- Subject: Re: TREE_ADDRESSABLE types cause ICE in declare_return_variable
- References: <loom.20130221T163946-827@post.gmane.org>
On Thu, Feb 21, 2013 at 7:58 AM, Johannes Pfau <johannespfau@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