<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Inaccessible base not diagnosed in expression using the pointer-to-member operators"
   href="http://llvm.org/bugs/show_bug.cgi?id=19274">19274</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inaccessible base not diagnosed in expression using the pointer-to-member operators
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>filip.roseen@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12307" name="attach_12307" title="testcase.cpp">attachment 12307</a> <a href="attachment.cgi?id=12307&action=edit" title="testcase.cpp">[details]</a></span>
testcase.cpp

struct A { int a = 0; };
struct B : private A { };

int
main (int argc, char *argv[])
{
  int A::* ptr = &A::a;

  B ().*ptr; // ill-formed
}


----------------------------------------------------------------

The following should issue a diagnostic saying that our source is ill-formed,
`clang` however compiles and accepts it. `A` is not an accessible base of `B`,
therefore the line marked `// ill-formed` should error.

`gcc` shows the correct behaviour with the following diagnostic:

<span class="quote">> testcase.cpp: In function ‘int main(int, char**)’:
> testcase.cpp:9:9: error: ‘A’ is an inaccessible base of ‘B’
>    B ().*ptr; // ill-formed</span >



[expr.mptr.oper]p2 states the following:

  > The binary operator `.*` binds its second operand, which shall be
  > of type "pointer to member of T", to its first operand, which
  > shall be of class T or of a class of which T is an unambiguous and
  > accessible base class. The result is an object or a function of
  > the type specified by the second operand.



[ Note: the same applies to `->*` ]</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>