http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45586
--- Comment #81 from Mikael Morin <mikael at gcc dot gnu.org> 2012-08-01 18:37:55 UTC --- (In reply to comment #79) > If that's valid then you can make the middle-end happy by wrapping > the RHS inside a VIEW_CONVERT_EXPR with the LHS type. OK. will try. I don't know yet though how to limit that to the very cases where it is necessary. (In reply to comment #80) > I have not closely looked at the dump, however, > this%y = this%find_y() > means that one assigns component-wise the values from the RHS to the LHS; if > there are pointer components, the pointer address is assigned; if there are > allocatable components, those are - if needed - first (re)allocated and then > (element-wise) assigned. > > Thus, one only assigns the values and no pointers - and, hence, the RHS can be > a nontarget while the LHS can be a target. > Actually, there is a wrong-code bug about exactly this line (see bugs #47455 and #47586). But I think that even if there wasn't, the middle-end wouldn't be happy about it. The values are assigned component-wise, and that's the only way the middle-end would accept it.