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

COMP: Fix MSVC error C2516: 'ConstIterator': is not a legal base class #3844

Conversation

N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Jan 2, 2023

Originally reported by Astha, March 14, 2022, and further discussed at "ITK build Error in itk::ShapedNeighborhoodIterator", https://discourse.itk.org/t/itk-build-error-in-itk-shapedneighborhooditerator/4861

@github-actions github-actions bot added area:Core Issues affecting the Core module type:Compiler Compiler support or related warnings labels Jan 2, 2023
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Jan 2, 2023

Thanks to Bernhard Froehler (@codeling) for confirming that the errors go away with this fix, at https://discourse.itk.org/t/itk-build-error-in-itk-shapedneighborhooditerator/4861/19

@N-Dekker N-Dekker marked this pull request as ready for review January 2, 2023 19:07
@@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT ShapedNeighborhoodIterator
using typename Superclass::IndexValueType;

/** An iterator for the ShapedNeighborhood classes. */
struct Iterator : public ConstIterator
struct Iterator : public Superclass::ConstIterator
Copy link
Contributor Author

@N-Dekker N-Dekker Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Instead of this adjustment (deriving from Superclass::ConstIterator), we could also restore using ConstIterator = typename Superclass::ConstIterator; as in

using ConstIterator = typename Superclass::ConstIterator;

It looks like these MSVC /permissive- errors were triggered by pull request #2567 commit 4f30980 "STYLE: Avoid repeating parent aliases", merged on September 21, 2021. I still think it may be an MSVC compiler bug anyway.

@N-Dekker N-Dekker marked this pull request as draft January 3, 2023 13:52
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Jan 3, 2023

PR converted back to draft, because this error appears elsewhere in ITK as well, when doing /permissive- compilation:

using typename Superclass::GlobalDataStruct;
struct ShapePriorGlobalDataStruct : public GlobalDataStruct

Works around compile errors that appeared using Visual C++ compiler flag
`/permissive-` ("Conformance mode"), using either VS2019 or VS2022, saying:

> error C2516: 'ConstIterator': is not a legal base class
> error C2516: 'GlobalDataStruct': is not a legal base class

Originally reported by Astha, March 14, 2022, and further discussed at
"ITK build Error in itk::ShapedNeighborhoodIterator",
https://discourse.itk.org/t/itk-build-error-in-itk-shapedneighborhooditerator/4861
@N-Dekker N-Dekker force-pushed the Fix-MSVC-error-C2516-ConstIterator branch from 872fa19 to ad1277b Compare January 3, 2023 14:30
@github-actions github-actions bot added the area:Segmentation Issues affecting the Segmentation module label Jan 3, 2023
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Jan 3, 2023

Please check the bug report I submitted to Microsoft on this compile error: Class template gets undeserved error C2516: "is not a legal base class" from /permissive- ("Conformance mode") And please upvote the bug report!

https://developercommunity.visualstudio.com/t/Class-template-gets-undeserved-error-C25/10243790

@N-Dekker N-Dekker marked this pull request as ready for review January 3, 2023 23:42
@dzenanz dzenanz merged commit 687f51e into InsightSoftwareConsortium:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Segmentation Issues affecting the Segmentation module type:Compiler Compiler support or related warnings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants