You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue arises when I want to access base class function by referring through type alias for that base class (self.Base::solve()). In ExtraVerboseSolver example it seems that Base type alias visible in VerboseSolver::solve is one defined in ExtraVerboseSolver which leads to infinite recursion VerboseSolver::solve -> VerboseSolver::solve. As far as I can guess it looks like that Base alias in VerboseSolver is shadowed by Base alias in ExtraVerboseSolver as if "deducing this" contributed to type alias resolution as well. It can be mitigated by using base class name instead of a type alias. However GCC doesn't require that mitigation and behaviour follows my virtual functions example. Example on Godbolt for all three major compilers with and without type alias: https://godbolt.org/z/4fYK8s344
Unfortunately I don't know what's standard compliant behaviour hence the question in the title. Is GCC right in this case?
The text was updated successfully, but these errors were encountered:
I have an inheritance chain where derived class does something extra before delegating to base class implementation.
Here's an example implementing this kind of behaviour with virtual functions
Expected outcome:
Example on Godbolt. All three major compilers agree on the visible behaviour.
I've tried expressing this behaviour with "deducing this" feature to avoid virtual functions and maintain cooperative nature of all these classes.
Code:
The issue arises when I want to access base class function by referring through type alias for that base class (
self.Base::solve()
). InExtraVerboseSolver
example it seems thatBase
type alias visible inVerboseSolver::solve
is one defined inExtraVerboseSolver
which leads to infinite recursionVerboseSolver::solve -> VerboseSolver::solve
. As far as I can guess it looks like thatBase
alias inVerboseSolver
is shadowed byBase
alias inExtraVerboseSolver
as if "deducing this" contributed to type alias resolution as well. It can be mitigated by using base class name instead of a type alias. However GCC doesn't require that mitigation and behaviour follows my virtual functions example. Example on Godbolt for all three major compilers with and without type alias: https://godbolt.org/z/4fYK8s344Unfortunately I don't know what's standard compliant behaviour hence the question in the title. Is GCC right in this case?
The text was updated successfully, but these errors were encountered: