It may also be reasonable for someone to do

void F(C &&o) {
    A_MightTake(move(o));
    B_MightTake(move(o));
    ...
}

to let a sequence of functions examine an object
and maybe take it, maybe not.  First one that
wants it, gets it, the rest see a moved-from
empty object.

On Thu, Jun 22, 2023 at 11:39 AM Thiago Macieira via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
On Thursday, 22 June 2023 06:30:05 PDT Frederick Virchanza Gotham via Std-
Proposals wrote:
> Make it compulsory for a compiler to issue a diagnostic (and possibly
> also terminate compilation) in the following scenario:
>
>     void Func(SomeClass &&obj)
>     {
>         SomeOtherFunc( move(obj) );
>
>         AndAgainSomeOtherFunction( move(obj) );
>     }

clang-tidy already issues this warning. I see no reason why a compiler
couldn't do it too. This means it's QoI, so please open a request with your
vendor for them to do it.

The code above is NOT ill-formed and there's nothing the standard can do to
enforce. The classes in question could abuse rvalue mechanisms to store an
output value in "obj" which can be passed from object to object.


--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering



--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals