<div dir="ltr">Hello all,<div><br></div><div>I've encountered a strange behaviour while messing with virtual inheritance. Assume that we have the following structures;</div><div><br></div><div>struct foo{ <br>    void f(){}<br>};<br></div><div><br></div><div>template<typename B><br>struct bar : private virtual B{ }; // A template struct which uses CRTP<br></div><div><br></div><div>struct zxe : public foo{};<br></div><div><br></div><div>And we have a struct, which inherits from both zxe, and bar at the same time.</div><div><br></div><div>struct qua  :  public bar<zxe>,       // restricting foo access  </div><div>                     public virtual zxe      // providing public foo access                         <br>{ };<br></div><div><br></div><div>int main(void) {<br>    qua q;<br>    q.f();<br>}</div><div><br></div><div>When we try to call f() on an instance of qua, the compiler throws the following error;</div><div><br></div><div>"cannot cast 'qua' to its private base class 'foo'"</div><div><br></div><div>But, if we change order of inheritance, the error disappears.<br><br></div><div><div>struct qua  :  public virtual zxe,      // providing public foo access     </div><div>                     public bar<zxe>        // restricting foo access             </div><div>{ };</div></div><div><br></div><div>Is this a bug, or related to standard?  I've tried same example in GCC 9.1, 8.1, 4.9 and both versions are compiled just fine. </div><div><br></div><div>The full error log is available in attachments.</div><div><br></div><div>Thanks in advance,</div><div>Mustafa</div><div><br></div><div><br></div></div>