COMP: Avoid Superclass type alias GCC compile errors#2720
Conversation
jhlegarreta
left a comment
There was a problem hiding this comment.
Although I do not have a better proposal (sorry), I am not sure avoiding to print the superclass name is what we would like as a mid-/long-term fix.
I find particularly worrying that this is only happening for a few classes in the review module; the macro is used extensively throughout the code and the faulty statements are working well. So I think there is something more behind it that we are not being able to identify.
As for the proposed fix, if this is what we aim at for now, am I wrong when saying that the only statements that should need to be within the if/else are those related to the superclass? i.e. That the rest of the code is exactly the same, and we could avoid duplicating it?
|
In #2676, the |
This results in the same error with GCC 9.3.0. |
|
Windows complaints might have to do with the comments in #2720 (comment): |
|
Grasping at straws, but ... in, e.g., |
dzenanz
left a comment
There was a problem hiding this comment.
Would a simple switch to (*object).Superclass::GetNameOfClass() help?
I am trying this on my Linux box.
Closes InsightSoftwareConsortium#2676. Suggested by Lee Newberg in PR InsightSoftwareConsortium#2720: InsightSoftwareConsortium#2720 (comment)
Closes InsightSoftwareConsortium#2676. Suggested by Lee Newberg in PR InsightSoftwareConsortium#2720: InsightSoftwareConsortium#2720 (comment)
Closes InsightSoftwareConsortium#2676. Suggested by Lee Newberg in PR InsightSoftwareConsortium#2720: InsightSoftwareConsortium#2720 (comment)
|
Lee's suggestion does not work: |
|
/azp run ITK.Windows |
I was tempted to push a PR with that, but I found many counter-examples (classes whose RTTI macro declaration comes after the Even in the |
a574d04 to
c238b76
Compare
jhlegarreta
left a comment
There was a problem hiding this comment.
Not sure how to make the linter happy.
Thanks for doing this @thewtex.
|
If we can't make clang-format happy, there is |
GCC is not resolving `object->Superclass` in some cases even though the definition is available and other compilers are resolving the definition. xref InsightSoftwareConsortium#2676
c238b76 to
230be6b
Compare
|
Maybe something like this would work: #if defined(__GNUC__)
#define ITK_EXERCISE_BASIC_OBJECT_METHODS(object, ClassName, SuperclassName) \
object->Print(std::cout); \
std::cout << "Name of Class = " << object->GetNameOfClass() << std::endl; \
using self_t = std::remove_reference<decltype(*object)>::type; \
using parent_t = typename self_t::Superclass; \
std::cout << "Name of Superclass = " << dynamic_cast<parent_t&>(*object).GetNameOfClass() << std::endl; \
ITK_MACROEND_NOOP_STATEMENT |
GCC is not resolving
object->Superclassin some cases even though thedefinition is available and other compilers are resolving the
definition.
xref #2676