<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/126787>126787</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Initializing base class from derived class: access check missing?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          csimon-bambecksystems
      </td>
    </tr>
</table>

<pre>
    This code is incorrectly accepted in clang 19.1.0:

```
#include <iostream>

class foo
{
public:
    foo(int i) { std::cout << "hello foo=" << i << "\n"; }
    foo() { std::cout << "hello foo\n"; }
};

class bar: private virtual foo   /// N.B.: "private" here means baz cannot access foo
{

};

class baz: public bar
{
public:
    // baz(): foo(42) {}   // not accepted -- calls inaccessible foo::foo(int) if baz is the most-derived object
    // baz(): foo() {}     // not accepted -- calls inaccessible foo::foo() if baz is the most-derived object
    baz() {} // accepted, incorrectly -- calls inaccessible foo::foo() if baz is the most-derived object!
};

int main()
{
    baz b;
 std::cout << "goodbye\n";
}
```

Output:

```
hello foo
goodbye
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVN2O8yYQfRp8M4qFwY7jC1_kp5F60970BQBje7oYIoMjZZ--wj-b3air9tP3SSgo5syZw5kZhPfYWa1rUpxIcUnEFHo31srj4OxOikFq9eYfPujBJ9I1j_qvHj0o12hAD2iVG0etgnmAUErfgm4ALSgjbAdZlWYpJfxI6Lz2dF30SBhHq8zUaCD8jM6HUYuB8N8WqDLCe2idi3_LE6HH2yQNqoULAOYzdkAbAAmrgJQn8KGJ5_yo3BQiLeFnIIz12hg3B_ALYWw7wU8QUpxt3PgJSHn5kuL_s79yxF9--nwhKUbCj3Ab8S6ChjuOYRImBgMAYddlwR_pKY04wtgKjbJ7PWoYtLCR5x2UsNaF2fUXq75J_T6nnm2chXzn7CoiBsy3j2GLFTlbzSDl5QncVMy13-1ACWNiZyzKUBq9eB-9-6haJMJ2vgh6CL2Gwfmwa_SId92Ak39rFf5T0Bc5PyHoR9R8yNgyr1m3jISdv4zFLxTAspfSxvYfBNrVl62iq0yQC_Db1u2ca-RDPxt3pX8ZVXr8cwq3KfzrID_bnx43vk-IpKl5U_FKJLrOSl5xyst9kfR1oZp9dqBZK0uZiSJrc0HbQ962OS9VWxQJ1oyygrIsy6piT_O0kRlXVV7tRZWrViiSUz0INKkx9yF1Y5eg95OuM7YvD2VihNTGb-_aWEfUTk6dJzk16IN_xgUMRte_WwwoDL6j7UAKr2F9hUY3wFaJ-VNswHXuVK_VGwzoPdqO8GsyjabuQ7hF0NIZHYZ-kqlyA2HXmHPddrfRLWW9zsI9YddV-71m_wQAAP__ph6l_g">