lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Detecting whether move semantics actually take place [Was: Install


From: Greg Chicares
Subject: [lmi] Detecting whether move semantics actually take place [Was: Install several more clang packages]
Date: Mon, 18 Jul 2022 15:48:14 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 7/18/22 14:51, Vadim Zeitlin wrote:
> On Mon, 18 Jul 2022 10:33:20 -0400 (EDT) Greg Chicares 
> <gchicares@sbcglobal.net> wrote:
[...]
> GC>     Install several more clang packages
[...]
>  FWIW I don't think you're going to find clang-format useful.

Thanks for letting me know. I won't remove it from the list of
packages, just in case it becomes useful someday.

I was really just hoping to use 'clang-tidy'. So far, I've
figured out that I need '-extra-arg=-std=c++20', and I've
tested one tiny file.

Let me pose a hypothetical question first: does this line
     db = std::move(da);   // D& operator=(D&&)
actually perform a move and not a copy, in a context where
class D defaults all special member functions?

Here's what 'clang-tidy' says:

clang-tidy sandbox_test.cpp -extra-arg=-std=c++20 2>&1 |less

/opt/lmi/src/lmi/sandbox_test.cpp:276:6: note: Moved-from object 'da' is moved
     db = std::move(da);   // D& operator=(D&&)
     ^~~~~~~~~~~~~~~~~~

so it appears to detect that the intention of that line of
code is actually realized. On a large code base, that sort
of information might be overwhelming. But for this little
test, it has real value. A move assignment operator might be
undeclared, or inaccessible, or deleted, and in all (AFAIK)
of those cases, copy assignment would silently be substituted.
There doesn't seem to be a C++ standard way to ascertain
whether a move actually takes place. But the compiler surely
knows what it did, and a tool built on top of the compiler
can give this information.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]