+1 vote
asked by (1.2k points)

Hi Miles,

When I install ITensor on macOS Mojave 10.14.2, there are some warnings like:

Compiling itensor/iqtensor.cc with optimizations
iqtensor.cc:428:26: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
newind.nextIndex(std::move(dag(I)));
^
iqtensor.cc:428:26: note: remove std::move call here
newind.nextIndex(std::move(dag(I)));
^~~~~~~~~~ ~
In file included from iqtensor.cc:11:
In file included from /Users/jin/itensor/itensor/iqtensor.h:7:
In file included from /Users/jin/itensor/itensor/itensor.h:7:
In file included from /Users/jin/itensor/itensor/itensorinterface.h:582:
./itensor
interface_impl.h:737:67: warning: local variable 'B' will be copied despite being returned by name [-Wreturn-std-move]
operator
(ITensorT const& A, ITensorT&& B) { B = A; return B; }
^
/Users/jin/itensor/itensor/iqtensor_impl.h:125:23: note: in instantiation of function template specialization 'itensor::operator
' requested here
return setElt(iv) * toITensor(T);
^
./itensorinterfaceimpl.h:737:67: note: call 'std::move' explicitly to avoid copying
operator(ITensorT const& A, ITensorT&& B) { B *= A; return B; }
^
std::move(B)
2 warnings generated.

Any suggestions for how to fix it? Thanks.

Jin

commented by (1.2k points)
I removed "std::move" in "std::move(dag(I))" and added "std::move" into "return B" as suggested. The warnings disappear. But I don't know if this will mess up something or not.
commented by (14.1k points)
Thanks for reporting this! When I compile on macOS Mojave 10.14.2 with the clang++ compiler, I also see the first warning you report above ("iqtensor.cc:428:26: warning: moving a temporary object prevents copy elision"), but I don't see the second warning. It may just be a difference in the compiler (different compilers will warn about different things).

We will look into making changes so these warnings don't appear, but for now you can likely just ignore them. If you want to check to make sure your installation is working properly, from your base ITensor directory, enter the unittest directory with `cd unittest` and type `make` to compile and run all of the tests. If all of the tests compile and pass, your installation of ITensor is working correctly! Another good test is to enter the sample directory from your base ITensor directory with `cd sample` and type `make`, and then run the sample DMRG runs with commands like `./dmrg`. This is a good test that the DMRG code in ITensor is working correctly.

Cheers,
Matt
commented by (1.2k points)
Hi Matt,

I also compile with the clang++ compiler (version 7.0.1). All tests passed and the sample dmrg is working correctly. But they both generate the socond warning when I compile.

Jin

1 Answer

0 votes
answered by (70.1k points)

(Just marking this as answered, via Matt Fishman's comments above.)

Jin, I second Matt's comment that we appreciate you reporting this, as these are very likely mis-used or unnecessary std::move commands that we will remove to get rid of these warnings as well. Thanks!

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...