I create a project using libtorch 1.6 about 6-8 months ago (visual studio c++). Since then I’ve been upgrading the project as new versions of torch are releasad. However, since 1.8 I get very many warnings as I compile the code. Around 1000 of them, and I always find it a bit unsettling with warnings since it often is an indication that something bad might happen.
Most of the warnings are all of the same type (mainly C4624) so I give an example of each:
|Warning|C26110|Caller failing to hold lock ‘lock’ before calling function ‘std::lock_guardstd::mutex::~lock_guardstd::mutex’.|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\ATen\Context.h|318||
|Warning|C26439|This kind of function may not throw. Declare it ‘noexcept’ (f.6).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\ATen\core\TensorBody.h|206||
|Warning|C26451|Arithmetic overflow: Using operator ‘-’ on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator ‘-’ to avoid overflow (io.2).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\ATen\core\MT19937RNGEngine.h|159||
|Warning|C26478|Don’t use std::move on constant variables. (es.56).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\torch\csrc\api\include\torch\nn\modules\container\sequential.h|120||
|Warning|C26495|Variable ‘at::indexing::TensorIndex::integer_’ is uninitialized. Always initialize a member variable (type.6).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\ATen\TensorIndexing.h|130||
|Warning|C26812|The enum type ‘c10::DispatchKeySet::Full’ is unscoped. Prefer ‘enum class’ over ‘enum’ (Enum.3).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\c10\core\DispatchKeySet.h|44||
|Warning|C26817|Potentially expensive copy of variable ‘d’ in range-for loop. Consider making it a const reference (es.71).|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\ATen\core\jit_type.h|420||
|Warning|C4067|unexpected tokens following preprocessor directive - expected a newline|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\c10\macros\Macros.h|189||
|Warning|C4624|‘c10::trivially_copyable_optimization_optional_base’: destructor was implicitly defined as deleted|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\c10\util\Optional.h|387||
|Warning|C6308|‘realloc’ might return null pointer: assigning null pointer to ‘outOfLineStorage_’, which is passed as an argument to ‘realloc’, will cause the original memory block to be leaked.|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\c10\core\impl\SizesAndStrides.h|276||
|Warning|C6385|Reading invalid data from ‘device_guard_impl_registry’: the readable size is ‘104’ bytes, but ‘2048’ bytes may be read.|cstorchlib|C:\Packages\libtorch1.8.0-debug-cuda10.2\include\c10\core\impl\DeviceGuardImplInterface.h|219||
Are any of these warnings a potential problem and why did I start getting them when upgrading to a newer version of libtorch?