SGpp / SGpp

SG⁺⁺ – the numerical library for Sparse Grids in all their variants.
https://sgpp.sparsegrids.org
Other
70 stars 35 forks source link

Several compiler warnings with MSVC++ #254

Open crschnick opened 3 years ago

crschnick commented 3 years ago

When compiling sgpp with MSVC++, several warnings pop up that might indicate unintended behaviour:

\base\src\sgpp\base\grid\storage\hashmap\HashGridPoint.hpp(376,72): warning C4146: unary minus operator applied to unsigned type, result still unsigned
\base\src\sgpp\base\grid\storage\hashmap\HashGridPoint.hpp(398,72): warning C4146: unary minus operator applied to unsigned type, result still unsigned
\base\src\sgpp\base\grid\storage\hashmap\HashGridPoint.hpp(426,71): warning C4146: unary minus operator applied to unsigned type, result still unsigned
\base\src\sgpp\base\grid\common\IndexInSubspaceGenerator.hpp(51,23): warning C4834: discarding return value of function with 'nodiscard' attribute
\base\src\sgpp\base\operation\hash\common\basis\PolyBasis.hpp(167,24): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
\base\src\sgpp\base\operation\hash\common\basis\BsplineBasis.hpp(1645,1): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
crschnick commented 3 years ago

Now that I have adjusted the warning levels, there are several more warnings:

1>C:\Projects\sgpp_dev\winsgpp\base\src\sgpp\base\grid\common\IndexInSubspaceGenerator.hpp(51,23): warning C4834: discarding return value of function with 'nodiscard' attribute
1>C:\Projects\sgpp_dev\winsgpp\base\src\sgpp\base\grid\generation\refinement_strategy\ForwardSelectorRefinement.cpp(147,19): warning C4834: discarding return value of function with 'nodiscard' attribute
1>C:\Projects\sgpp_dev\winsgpp\base\src\sgpp\base\grid\generation\refinement_strategy\ImpurityRefinement.cpp(153,19): warning C4834: discarding return value of function with 'nodiscard' attribute
1>C:\Projects\sgpp_dev\winsgpp\base\src\sgpp\base\grid\generation\refinement_strategy\PredictiveRefinement.cpp(148,19): warning C4834: discarding return value of function with 'nodiscard' attribute
1>C:\Projects\sgpp_dev\winsgpp\base\src\sgpp\base\grid\common\IndexInSubspaceGenerator.hpp(51,23): warning C4834: discarding return value of function with 'nodiscard' attribute

3>C:\Projects\sgpp_dev\winsgpp\combigrid\src\sgpp\combigrid\grid\FullGrid.cpp(36,31): warning C4804: '>=': unsafe use of type 'bool' in operation
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(2892,24): warning C4244: '=': conversion from 'double' to 'unsigned __int64', possible loss of data
3>C:\Projects\sgpp_dev\winsgpp\combigrid\tests\test_combigrid.cpp(362): message : see reference to function template instantiation '_OutIt std::transform<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<unsigned __int64>>>,testCombinationGridTruncated::test_method::<lambda_8fa4b6bb5ef4097bc5c39c6687f30de2>>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled
3>        with
3>        [
3>            _OutIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<size_t>>>,
3>            _Ty=sgpp::combigrid::LevelVector,
3>            _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<sgpp::combigrid::LevelVector>>>,
3>            _Fn=testCombinationGridTruncated::test_method::<lambda_8fa4b6bb5ef4097bc5c39c6687f30de2>
3>        ]
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\numeric(35,1): warning C4267: '=': conversion from 'size_t' to '_Ty', possible loss of data
3>        with
3>        [
3>            _Ty=int
3>        ]
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\numeric(44): message : see reference to function template instantiation '_Ty std::accumulate<_InIt,_Ty,std::plus<void>>(const _InIt,const _InIt,_Ty,_Fn)' being compiled
3>        with
3>        [
3>            _Ty=int,
3>            _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<size_t>>>,
3>            _Fn=std::plus<void>
3>        ]
3>C:\Projects\sgpp_dev\winsgpp\combigrid\tests\test_combigrid.cpp(363): message : see reference to function template instantiation '_Ty std::accumulate<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<unsigned __int64>>>,int>(const _InIt,const _InIt,_Ty)' being compiled
3>        with
3>        [
3>            _Ty=int,
3>            _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<size_t>>>
3>        ]
2>C:\Projects\sgpp_dev\winsgpp\optimization\src\sgpp\optimization\tools\FileIO.hpp(274,10): warning C4834: discarding return value of function with 'nodiscard' attribute
2>C:\Projects\sgpp_dev\winsgpp\optimization\src\sgpp\optimization\tools\FileIO.cpp(174): message : see reference to function template instantiation 'void sgpp::optimization::file_io::readMatrix<double>(const std::string &,std::vector<double,std::allocator<double>> &,size_t &,size_t &)' being compiled
2>C:\Projects\sgpp_dev\winsgpp\optimization\src\sgpp\optimization\tools\FileIO.hpp(274,10): warning C4834: discarding return value of function with 'nodiscard' attribute
2>C:\Projects\sgpp_dev\winsgpp\optimization\tests\testTools.cpp(149): message : see reference to function template instantiation 'void sgpp::optimization::file_io::readMatrix<double>(const std::string &,std::vector<double,std::allocator<double>> &,size_t &,size_t &)' being compiled
2>C:\Projects\sgpp_dev\winsgpp\optimization\tests\testTools.cpp(220): message : see reference to function template instantiation 'void testReadWriteMatrix<double>(std::vector<double,std::allocator<double>> &,size_t,size_t)' being compiled
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1091,5): warning MSB8027: Two or more files with the name of test_rosenblattTransformation.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are C:\Projects\sgpp_dev\winsgpp\datadriven\tests\pipeline\test_rosenblattTransformation.cpp, C:\Projects\sgpp_dev\winsgpp\datadriven\tests\test_RosenblattTransformation.cpp.
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(2916,1): warning C4267: 'argument': conversion from 'size_t' to 'const _Ty', possible loss of data
6>        with
6>        [
6>            _Ty=int
6>        ]
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\algorithm\CombiScheme.cpp(118): message : see reference to function template instantiation '_OutIt std::transform<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<unsigned __int64>>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<unsigned __int64>>>,std::plus<_Ty>>(const _InIt1,const _InIt1,const _InIt2,_OutIt,_Fn)' being compiled
6>        with
6>        [
6>            _OutIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<size_t>>>,
6>            _Ty=int,
6>            _InIt1=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>,
6>            _InIt2=std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<size_t>>>,
6>            _Fn=std::plus<int>
6>        ]
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\datamining\modules\dataSource\DataSourceConfig.hpp(81,27): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\datamining\modules\dataSource\DataSourceConfig.hpp(125,31): warning C4838: conversion from 'int' to 'size_t' requires a narrowing conversion
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7245,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7369): message : see reference to function template instantiation '_BidIt std::_Insertion_sort_unchecked<_RanIt,_Pr>(const _BidIt,const _BidIt,_Pr)' being compiled
6>        with
6>        [
6>            _BidIt=unsigned __int64 *,
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7399): message : see reference to function template instantiation 'void std::_Sort_unchecked<unsigned __int64*,_Fn>(_RanIt,_RanIt,__int64,_Pr)' being compiled
6>        with
6>        [
6>            _Fn=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>,
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\datamining\modules\hpo\harmonica\Harmonica.cpp(109): message : see reference to function template instantiation 'void std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>>(const _RanIt,const _RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _Ty=size_t,
6>            _RanIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<size_t>>>,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7245,17): warning C4244: 'argument': conversion from 'unsigned __int64' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7249,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7249,44): warning C4244: 'argument': conversion from 'unsigned __int64' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7302,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7380): message : see reference to function template instantiation 'std::pair<_RanIt,_RanIt> std::_Partition_by_median_guess_unchecked<_RanIt,_Pr>(_RanIt,_RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7303,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7307,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7316,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7318,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7329,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7331,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5685,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5851): message : see reference to function template instantiation 'void std::_Pop_heap_hole_by_index<_RanIt,unsigned __int64,_Pr>(_RanIt,__int64,__int64,_Ty &&,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>,
6>            _Ty=unsigned __int64
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7374): message : see reference to function template instantiation 'void std::_Make_heap_unchecked<_RanIt,_Pr>(_RanIt,_RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5563,26): warning C4244: 'argument': conversion from '_Ty' to 'int', possible loss of data
6>        with
6>        [
6>            _Ty=unsigned __int64
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5697): message : see reference to function template instantiation 'void std::_Push_heap_by_index<_RanIt,_Ty,_Pr>(_RanIt,__int64,__int64,_Ty &&,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Ty=unsigned __int64,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5851): message : see reference to function template instantiation 'void std::_Pop_heap_hole_by_index<_RanIt,unsigned __int64,_Pr>(_RanIt,__int64,__int64,_Ty &&,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>,
6>            _Ty=unsigned __int64
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(5563,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7264,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7285): message : see reference to function template instantiation 'void std::_Med3_unchecked<_RanIt,_Pr>(_RanIt,_RanIt,_RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7298): message : see reference to function template instantiation 'void std::_Guess_median_unchecked<_RanIt,_Pr>(_RanIt,_RanIt,_RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7380): message : see reference to function template instantiation 'std::pair<_RanIt,_RanIt> std::_Partition_by_median_guess_unchecked<_RanIt,_Pr>(_RanIt,_RanIt,_Pr)' being compiled
6>        with
6>        [
6>            _RanIt=unsigned __int64 *,
6>            _Pr=sgpp::datadriven::Harmonica::calculateConstrainedSpace::<lambda_17fe68f39b35de053e3ad5112b509b9b>
6>        ]
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7268,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\algorithm(7271,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\OperationMultiEvalModMaskStreaming\OperationMultiEvalModMaskStreaming_multImpl.cpp(620,17): warning C4081: expected '('; found 'string'
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\OperationMultiEvalModMaskStreaming\OperationMultiEvalModMaskStreaming_multTransposeImpl.cpp(496,5): warning C4081: expected '('; found 'string'
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\OperationMultiEvalStreaming\OperationMultiEvalStreaming_multImpl.cpp(589,17): warning C4081: expected '('; found 'string'
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\OperationMultiEvalStreaming\OperationMultiEvalStreaming_multTransposeImpl.cpp(485,5): warning C4081: expected '('; found 'string'
6>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\utility(193,54): warning C4244: 'initializing': conversion from 'size_t' to '_Ty2', possible loss of data
6>        with
6>        [
6>            _Ty2=double
6>        ]
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\simple\OperationRosenblattTransformation1DLinear.cpp(48): message : see reference to function template instantiation 'std::pair<double,double>::pair<_Ty&,size_t&,0>(_Other1,_Other2) noexcept' being compiled
6>        with
6>        [
6>            _Ty=double,
6>            _Other1=double &,
6>            _Other2=size_t &
6>        ]
6>C:\Projects\sgpp_dev\winsgpp\datadriven\src\sgpp\datadriven\operation\hash\simple\OperationRosenblattTransformation1DLinear.cpp(48): message : see reference to function template instantiation 'std::pair<double,double>::pair<_Ty&,size_t&,0>(_Other1,_Other2) noexcept' being compiled
6>        with
6>        [
6>            _Ty=double,
6>            _Other1=double &,
6>            _Other2=size_t &
6>        ]