https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128168

--- Comment #2 from Yongqiang Tian <yqtian668 at gmail dot com> ---
(In reply to Drea Pinski from comment #1)
> This case might be undefined.

Hi Drea,

thanks for the comment. Frankly speaking, I am not an expert in this so my
reading could be wrong. 

To my understanding, [class.cdtor]/4 covers virtual calls made directly or
indirectly from a constructor. If the call applies to the object under
construction, the selected function is the final overrider in the constructor's
class. Here B::B() is executing, and r denotes the A virtual-base subobject of
that B object, so I think the selected function should be B::f().

The example in [class.cdtor]/4 also seems closely analogous: a call through a
pointer to a virtual base of B during B::B() is described as well-defined and
calls B's override. The undefined call in that example is through a sibling
base that is not a base of B, which does not appear to be the case here.

The conversion from B& to its virtual base A& also appears to satisfy
[class.cdtor]/3, since it occurs in the body of B::B(), after construction of B
and its virtual base has started.

Please let me know if I have overlooked a different rule that makes this case
undefined. Really appreciated it. 

Thanks a lot.

https://eel.is/c++draft/class.cdtor#4
https://eel.is/c++draft/class.cdtor#3

Reply via email to