ITK icon indicating copy to clipboard operation
ITK copied to clipboard

[MSVC][C++23] ITK's copy of KWSys is returning 0 as std::string

Open QuellaZhang opened this issue 4 years ago • 11 comments

Hi all,

This is the more errors from https://github.com/InsightSoftwareConsortium/ITK/issues/2637. Notice "Modules/ThirdParty/KWSys/src/KWSys/SystemTools.cxx" has been fixed, but the one under build dir still failed, not sure if they are the same file. Using latest code 8aed68490b733ba45b36b2e8e84e99980db45948.

error C2666 should be another issue.

Build steps:

  1. open VS2019 x86 tools command
  2. git clone https://github.com/InsightSoftwareConsortium/ITK F:\gitP\InsightSoftwareConsortium\ITK
  3. mkdir build_x86 && build_x86
  4. cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DBUILD_EXAMPLES=OFF ..
  5. set CL=/D_HAS_AUTO_PTR_ETC=1 /D_HAS_TR1_NAMESPACE=1 /D_HAS_DEPRECATED_RESULT_OF=1 /D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING /D_HAS_DEPRECATED_UNCAUGHT_EXCEPTION=1 /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING /std:c++latest /Zc:twoPhase- /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
  6. msbuild /m /p:Platform=Win32 /p:Configuration=Release All_BUILD.vcxproj /t:Rebuild

Build.log: build (3).log

F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\c++\src\H5PropList.cpp(558,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits,std::allocator>' [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\Modules\ThirdParty\HDF5\src\itkhdf5\c++\src\hdf5_cpp-static.vcxproj]

F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle\Utilities\KWSys\SystemTools.cxx(4238,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits,std::allocator>' [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle-build\Utilities\KWSys\kwssys.vcxproj] [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle.vcxproj] F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle\Utilities\KWSys\SystemTools.cxx(4377,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits,std::allocator>' [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle-build\Utilities\KWSys\kwssys.vcxproj] [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle.vcxproj] F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle\Utilities\KWSys\SystemTools.cxx(4384,1): error C2440: 'return': cannot convert from 'int' to 'std::basic_string<char,std::char_traits,std::allocator>' [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle-build\Utilities\KWSys\kwssys.vcxproj] [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\KWStyle.vcxproj]

F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\GoogleTest\src\itkgoogletest\googletest\include\gtest/gtest.h(1527,1): error C2666: 'itk::FixedArray<double,2>::operator ==': 2 overloads have similar conversions [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\Modules\Core\Transform\test\ITKTransformGTestDriver.vcxproj] F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\GoogleTest\src\itkgoogletest\googletest\include\gtest/gtest.h(1527,1): error C2666: 'itk::FixedArray<T,3>::operator ==': 2 overloads have similar conversions [F:\gitP\InsightSoftwareConsortium\ITK\build_x86\Modules\Core\Transform\test\ITKTransformGTestDriver.vcxproj]

QuellaZhang avatar Jul 13 '21 09:07 QuellaZhang

KWStyle, a style checker tool ITK uses, has its own copy of KWSys. I will update it and I guess that will fix 3 instances.

The other errors are related to third party libraries we don't control (HDF5 and GTest). We can look into GTest one, as it seems to arise from our invocation. For HDF5, the solution will probably be to just update to newer version which has the fix.

dzenanz avatar Jul 13 '21 15:07 dzenanz

Thanks @dzenanz! Verified the 3 instances have been fixed. For HDF5, I can patch it first.

QuellaZhang avatar Jul 14 '21 10:07 QuellaZhang

Following the repro steps, I run into cl : command line error D8016: '/std:c++latest' and '/std:c11' command-line options are incompatible [C:\Misc\ITK-patches2-23\Modules\ThirdParty\VNL\src\vxl\v3p\netlib\itkv3p_netlib.vcxproj].

dzenanz avatar Jul 14 '21 19:07 dzenanz

Yes, I also encountered this issue before, but this issue is still in MSVC‘s SuggestionTicket, so I just patch it locally under /std:c++latest mode to unblock test.

itk_c11_error_OSSOptionCppLatest.patch.txt

2 related feedbacks: https://developercommunity.visualstudio.com/t/vs2019-169-preview-3-cl-command-line-error-d8016-s/1343268 https://developercommunity2.visualstudio.com/t/C-and-C-standard-options-should-not-be/1289751

QuellaZhang avatar Jul 15 '21 06:07 QuellaZhang

Did PR #2564 help with GTest errors?

dzenanz avatar Jul 20 '21 18:07 dzenanz

Thanks for the fix, but verified this issue still exists. I provide you with a pre-compiled file with corresponding error lines in it. Hope that helps.

itkMatrixOffsetTransformBaseGTest.i.txt error_message.txt

QuellaZhang avatar Jul 21 '21 07:07 QuellaZhang

@N-Dekker I think the problem is that we are comparing a FixedArray to a Point returned by GetCenter(): https://github.com/InsightSoftwareConsortium/ITK/blob/230d319fdeaa3877273fab5d409dd6c11f0a6874/Modules/Core/Transform/test/itkMatrixOffsetTransformBaseGTest.cxx#L39 and the compiler is confused about which class' equality operator to use. Should we solve this by a static_cast or something else?

dzenanz avatar Jul 21 '21 14:07 dzenanz

static_cast<itk::FixedArray<double, NDimensions>>(transformBase->GetCenter()) does resolve the compile errors.

dzenanz avatar Jul 21 '21 14:07 dzenanz

@QuellaZhang #2684 should be the last piece of the puzzle for this issue. Can you confirm and close?

Updated HDF5 (#2683) does not have the fix, so #2684 was needed.

dzenanz avatar Aug 10 '21 22:08 dzenanz

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 10:04 stale[bot]

@QuellaZhang can you re-check that we resolved this?

dzenanz avatar Apr 16 '22 22:04 dzenanz

Closing the issue, presumably fixed.

dzenanz avatar Jan 24 '24 15:01 dzenanz