ITK source code incompatibility with C++20

Created on 17 Dec 2018  路  3Comments  路  Source: InsightSoftwareConsortium/ITK

A paper voted into the C++20 working draft changes the definition of aggregate such that classes with any user-declared ctors are no longer aggregates.

The MSVC team builds ITK regularly to detect regressions, and found this failure under our build configuration with the -std:c++latest switch. We are using the following backwards-compatible patch going forward, which you are free to upstream it if C++20 compatibility is on the library's radar.

Patch: itk_latest_c2440.patch.txt

Failures:
D:llvmsrctoolsclanglibToolingRefactoringASTSelection.cpp(354): error C2440: 'initializing': cannot convert from 'initializer list' to 'anonymous-namespace'::SelectedNodeWithParents' D:\llvm\src\tools\clang\lib\Tooling\Refactoring\ASTSelection.cpp(355): note: No constructor could take the source type, or constructor overload resolution was ambiguous D:\llvm\src\tools\clang\lib\Tooling\Refactoring\ASTSelection.cpp(362): error C2440: 'initializing': cannot convert from 'initializer list' to 'anonymous-namespace'::SelectedNodeWithParents'
D:llvmsrctoolsclanglibToolingRefactoringASTSelection.cpp(363): note: No constructor could take the source type, or constructor overload resolution was ambiguous

Compiler

Most helpful comment

@N-Dekker No problem. The rule of zero is clearly better in this case.

Software development is always a bit of a random-walk process. As long as we are headed in the right direction and just keep moving. :)

All 3 comments

Very interesting! Thanks, @QuellaZhang

Hans @hjmjohnson it's looks like most of these defaulted member function declarations were introduced with your commit 549a19c956bab2b41489816d8bb8d4bd09161583 (_STYLE: Change aggregate classes to mirror std::array_) Please consider removing them. From:

  • InformationValueType
  • Index
  • Offset
  • Size

Maybe also add a note to each of them, saying that these classes follow "the rule of zero", in order to allow aggregate initialization.

I'm sorry, because in general I do like all the C++11 style improvements in ITK.

@N-Dekker No problem. The rule of zero is clearly better in this case.

Software development is always a bit of a random-walk process. As long as we are headed in the right direction and just keep moving. :)

Thanks @N-Dekker @hjmjohnson, ITK works well now on MSVC. Thank you so much. :)

Was this page helpful?
0 / 5 - 0 ratings