# Warnings on macOS Mojave

+1 vote

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 (800 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 (1.3k 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 (800 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