https://bugs.llvm.org/show_bug.cgi?id=38761

            Bug ID: 38761
           Summary: Argument dependent lookup fails for a class nested in
                    its base
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to