https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108165

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #5)
> Sorry, I'm not sure if the false positive in comment 0 can be fixed.  I
> can't simply compare the type of the temporary argument and the return type,
> because we may be returning a subobject of the temporary argument, which is
> still dangerous.

Well, you could e.g. walk recursively all the TYPE_FIELDS of the type of the
temporary
and compare to the type the return type references.  If the temporary has some
subobject of that type or if the temporary itself has that type, warn,
otherwise not warn.
There would still be false positives and false negatives, but those are without
actually looking at the definition unavoidable.

Reply via email to