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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:ac26cfeca99c488213eaf76d767ec4470ba3cee9

commit r10-10667-gac26cfeca99c488213eaf76d767ec4470ba3cee9
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Wed Jan 12 09:47:46 2022 +0100

    c++: Silence -Wuseless-cast warnings during move [PR103480]

    This is maybe just a shot in the dark, but IMHO we shouldn't be diagnosing
    -Wuseless-cast on casts the compiler adds on its own when calling its move
    function.  We don't seem to warn when user calls std::move either.
    We call move on elinit (*NON_LVALUE_EXPR <(struct C[2] &&) &D.2497->b>)[0]
    so it is already an xvalue_p and try to static_cast it to struct C &&.
    But we don't warn e.g. on std::move (std::move (whatever)).

    Fixed by not doing the static cast and just returning expr from move
    if expr is already an xvalue.

    2022-01-11  Jakub Jelinek  <ja...@redhat.com>
                Jason Merrill  <ja...@redhat.com>

            PR c++/103480
            * tree.c (move): If expr is xvalue_p, just return expr without
            build_static_cast.

            * g++.dg/warn/Wuseless-cast2.C: New test.

    (cherry picked from commit 6bba184ccbf47368eaea27ee2c1e7b850526640b)
  • [Bug c++/103480] [10 Regression... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to