Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings possibly indicating problems #1652

Closed
dzenanz opened this issue Jan 12, 2024 · 3 comments · Fixed by #1660
Closed

Warnings possibly indicating problems #1652

dzenanz opened this issue Jan 12, 2024 · 3 comments · Fixed by #1660

Comments

@dzenanz
Copy link
Contributor

dzenanz commented Jan 12, 2024

This concatenation of strings is discarded:

ANTs/Examples/Atropos.cxx

Lines 1335 to 1344 in 2d3cefa

std::string("Options include the following: ") +
std::string(" Socrates: posteriorProbability = (spatialPrior)^priorWeight") +
std::string("*(likelihood*mrfPrior)^(1-priorWeight), ") + std::string(" Plato: posteriorProbability = 1.0, ") +
std::string(" Aristotle: posteriorProbability = 1.0, ") +
std::string(" Sigmoid: posteriorProbability = 1.0, ") /* +
std::string( " Zeno: posteriorProbability = 1.0\n" ) +
std::string( " Diogenes: posteriorProbability = 1.0\n" ) +
std::string( " Thales: posteriorProbability = 1.0\n" ) +
std::string( " Democritus: posteriorProbability = 1.0.\n" ) */
;

Maybe a semicolon on the previous line (1334) should be replaced by a plus sign?

Current Visual Studio (17.8.4) reports the following warning:
C:\Dev\ANTs\Examples\sccan.cxx(2593,8): warning C4858: discarding return value: The 'remove' and 'remove_if' algorithms return the iterator past the last element that should be kept. You need to call container.erase(result, container.end()) afterwards. In C++20, 'std::erase' and 'std::erase_if' are simpler replacements for these two steps.
That code should be checked, and if it is OK that line should be replaced by:

std::ignore = std::remove(args.begin(), args.end(), std::string(""));
@ntustison
Copy link
Member

Yes, that's correct (i.e., the semi-colon should be replaced by a plus sign).

dzenanz added a commit to dzenanz/ANTs that referenced this issue Jan 12, 2024
dzenanz added a commit to dzenanz/ANTs that referenced this issue Jan 12, 2024
dzenanz added a commit to dzenanz/ANTs that referenced this issue Jan 12, 2024
cookpa pushed a commit that referenced this issue Jan 12, 2024
* COMP: The Gaussian label interpolator does not need the vector comparer

Fixes the following compile error:

antsRegistration2DDouble.cxx
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: 'bool ants::VectorPixelCompare<RealType,1>::operator ()(const itk::Vector<TPixel,1> &,const itk::Vector<TPixel,1> &) const': cannot convert argument 1 from 'const _Kty' to 'const itk::Vector<TPixel,1> &' [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: with [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: [ [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: TPixel=RealType [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: ] [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: and [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: [ [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: _Kty=itk::NumericTraits<double>::RealType [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: ] [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: and [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: [ [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: TPixel=RealType [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17): error C2664: ] [C:\Dev\ANTs-VS22\ANTS-build\Examples\antsUtilities.vcxproj]
  (compiling source file '../../../ANTs/Examples/antsRegistration2DDouble.cxx')
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17):
  Reason: cannot convert from 'const _Kty' to 'const itk::Vector<TPixel,1>'
          with
          [
              _Kty=itk::NumericTraits<double>::RealType
          ]
          and
          [
              TPixel=RealType
          ]
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17):
  Constructor for class 'itk::Vector<TPixel,1>' is declared 'explicit'
          with
          [
              TPixel=RealType
          ]
  C:\Dev\ANTs\Examples\antsUtilities.h(376,3):
  see declaration of 'ants::VectorPixelCompare<RealType,1>::operator ()'
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17):
  while trying to match the argument list '(const _Kty, const _Keyty)'
          with
          [
              _Kty=itk::NumericTraits<double>::RealType
          ]
          and
          [
              _Keyty=double
          ]
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1610,17):
  the template instantiation context (the oldest one first) is
  	C:\Dev\ANTs\Examples\antsRegistration2DDouble.cxx(10,10):
  	see reference to function template instantiation 'int ants::DoRegistration<double,2>(itk::ants::CommandLineParser::Pointer &)' being compiled
  	C:\Dev\ANTs\Examples\make_interpolator_snip.tmpl(124,1):
  	see reference to class template instantiation 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>' being compiled
  	C:\Dev\ITK-git\Modules\Core\ImageFunction\include\itkLabelImageGaussianInterpolateImageFunction.hxx(41,1):
  	while compiling class template member function 'TOutput itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex(const itk::ContinuousIndex<TCoordRep,2> &,TOutput *) const'
          with
          [
              TOutput=itk::NumericTraits<double>::RealType,
              TCoordRep=double
          ]
  		C:\Dev\ITK-git\Modules\Core\ImageFunction\include\itkLabelImageGaussianInterpolateImageFunction.h(117,5):
  		see the first reference to 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex' in 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex'
  	C:\Dev\ITK-git\Modules\Core\ImageFunction\include\itkLabelImageGaussianInterpolateImageFunction.hxx(61,17):
  	see reference to class template instantiation 'std::map<TOutput,itk::NumericTraits<double>::RealType,TPixelCompare,std::allocator<std::pair<const TOutput,itk::NumericTraits<double>::RealType>>>' being compiled
          with
          [
              TOutput=itk::NumericTraits<double>::RealType,
              TPixelCompare=CompareType
          ]
  	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\map(72,20):
  	see reference to class template instantiation 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>' being compiled
          with
          [
              _Kty=itk::NumericTraits<double>::RealType,
              _Ty=itk::NumericTraits<double>::RealType,
              _Pr=CompareType,
              _Alloc=std::allocator<std::pair<const itk::NumericTraits<double>::RealType,itk::NumericTraits<double>::RealType>>
          ]
  	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1370,25):
  	while compiling class template member function 'std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const TOutput,itk::NumericTraits<double>::RealType>>>> std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::find(const double &)'
          with
          [
              TOutput=itk::NumericTraits<double>::RealType,
              _Kty=itk::NumericTraits<double>::RealType,
              _Ty=itk::NumericTraits<double>::RealType,
              _Pr=CompareType,
              _Alloc=std::allocator<std::pair<const itk::NumericTraits<double>::RealType,itk::NumericTraits<double>::RealType>>
          ]
  		C:\Dev\ITK-git\Modules\Core\ImageFunction\include\itkLabelImageGaussianInterpolateImageFunction.hxx(74,36):
  		see the first reference to 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::find' in 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex'
          with
          [
              _Kty=itk::NumericTraits<double>::RealType,
              _Ty=itk::NumericTraits<double>::RealType,
              _Pr=CompareType,
              _Alloc=std::allocator<std::pair<const itk::NumericTraits<double>::RealType,itk::NumericTraits<double>::RealType>>
          ]
  		C:\Dev\ITK-git\Modules\Core\ImageFunction\include\itkLabelImageGaussianInterpolateImageFunction.h(117,5):
  		see the first reference to 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex' in 'itk::LabelImageGaussianInterpolateImageFunction<ImageType,RealType,CompareType>::EvaluateAtContinuousIndex'
  	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1371,25):
  	see reference to function template instantiation 'std::_Tree_node<std::pair<const TOutput,itk::NumericTraits<double>::RealType>,std::_Default_allocator_traits<_Alloc>::void_pointer> *std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Find<double>(const _Other &) const' being compiled
          with
          [
              TOutput=itk::NumericTraits<double>::RealType,
              _Alloc=std::allocator<std::pair<const itk::NumericTraits<double>::RealType,itk::NumericTraits<double>::RealType>>,
              _Kty=itk::NumericTraits<double>::RealType,
              _Ty=itk::NumericTraits<double>::RealType,
              _Pr=CompareType,
              _Other=double
          ]
  	C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xtree(1361,50):
  	see reference to function template instantiation 'std::_Tree_find_result<std::_Tree_node<std::pair<const TOutput,itk::NumericTraits<double>::RealType>,std::_Default_allocator_traits<_Alloc>::void_pointer> *> std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Find_lower_bound<_Other>(const _Keyty &) const' being compiled
          with
          [
              TOutput=itk::NumericTraits<double>::RealType,
              _Alloc=std::allocator<std::pair<const itk::NumericTraits<double>::RealType,itk::NumericTraits<double>::RealType>>,
              _Kty=itk::NumericTraits<double>::RealType,
              _Ty=itk::NumericTraits<double>::RealType,
              _Pr=CompareType,
              _Other=double,
              _Keyty=double
          ]

* COMP: Fix compile errors related to operations of vector pixels

I don't know whether this is the right thing to do.
I was primarily trying to get it to compile.

* COMP: Fix unused variable warning

Message:

C:\Dev\ANTs\Examples\AverageAffineTransform.cxx(314,40): warning C4101: 'e': unreferenced local variable [C:\Dev\ANTs-SB\ANTS-build\Examples\l_AverageAffineTransform.vcxproj]

* COMP: Fix compile warnings

Example message:

C:\Dev\ANTs\ImageRegistration\itkAvantsMutualInformationRegistrationFunction.cxx(368,54): warning C4834: discarding return value of function with [[nodiscard]] attribute [C:\Dev\ANTs-SB\ANTS-build\Examples\l_ANTS.vcxproj]

Also use the new-style enums.

* ENH: Remove mentions of zlib

* ENH: Remove legacy functionality from ITK

* COMP: Fixing compile errors on Linux

* BUG: setting wrong indices

* BUG: Part of the description was discarded

Ref #1652.

* STYLE: Use // comment and apply clang-format

* ENH: Use a recent version of ITK
@dzenanz
Copy link
Contributor Author

dzenanz commented Jan 16, 2024

@cookpa There is just one warning when compiling ANTs normally: C:\Dev\ANTs\Examples\sccan.cxx(2593,8): warning C4858: discarding return value. I am not familiar with this code to be able to tell whether we should just ignore the warning.

@cookpa
Copy link
Member

cookpa commented Jan 17, 2024

This looks like it re-orders the args matrix to put non-empty strings first. It discards the returned iterator. I'm not sure what its purpose is, but possibly something to do with ANTsR or ANTsPy. I think the warning is safe to ignore

std::remove(args.begin(), args.end(), std::string(""));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants