<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Argument dependent lookup fails for a class nested in its base"
   href="https://bugs.llvm.org/show_bug.cgi?id=38761">38761</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Argument dependent lookup fails for a class nested in its base
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>martin.beran@kernun.cz
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code does not compile:

struct base {
    friend const base* enable_base(const base* b) { return b; }
};

struct a: base {
    struct b;
};

struct a::b: a {
};

struct ptr {
    void get_base() { a::b* obj = nullptr; enable_base(obj); }
};

int main()
{
    ptr().get_base();
    return 0;
}

$ c++ -o err err.cpp --std=c++17pokus.cpp:15:44: error: use of undeclared
identifier 'enable_base'
    void get_base() { a::b* obj = nullptr; enable_base(obj); }
                                           ^
1 error generated.


I think that ADL should add 'base' into the set of associated classes and find
friend enable_base, because 'base' is an indirect base of 'a::b' and a direct
base of 'a', which 'a::b' is nested in. I tested this behavior on FreeBSD 11.2
with Clang 6.0.0, 6.0.1, and 7.0.0 rc1, also on Ubuntu 18.04 with Clang 6.0.0.
GCC 7.3.0 on Ubuntu 18.04 compiles this code without the error. Un-nesting 'b'
from 'a' eliminates the error on all tested versions of Clang.</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>