Code: Select all
D:\FreeCADGit\src\Mod\Sketcher\App\planegcs\Geo.cpp(732,35): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
Code: Select all
D:\FreeCADGit\src\Mod\Sketcher\App\planegcs\Geo.cpp(732,35): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
They are used as, but i and k are also indices within of control points and intervals respectively. They need to be at least unsigned int to ensure that negative values aren't passed. In the problem line, however, d is a sub-sequence of control points, and values outside the indices may be valid, just that the value of the function there is zero.marioalexis wrote: ↑Sun Nov 20, 2022 1:06 am The use of the parameters k and i as size_t seems unnecessary. We can change it to int and change the System::addConstraintInternalAlignmentKnotPoint function accordingly.
All variables involved are actually int.
Edit: actually a cast is needed there too.
size_t should not be used as a function parameter, unless a size is really intended. There is case in the code were a knot index is passed (originally as int). This index is not checked for boundaries and it is assumed to be an unsigned int, although it is actually an int. Then, when there are comparisons with unsigned types this generates compiler warnings.
Here it is best to actually change the function to unsigned int, to convey this fact, that the function expects an unsigned int. This also bring a potential signed/unsigned warning to the user code, if the wrong type is used.