[llvm-bugs] [Bug 45216] New: CLANG including struct names when looking up namespace name candidates

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 16 08:13:58 PDT 2020


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

            Bug ID: 45216
           Summary: CLANG including struct names when looking up namespace
                    name candidates
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kjmathew at outlook.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The below code compiles on GCC but not on CLANG. Looks like CLANG is looking up
struct identifier names as ns_name candidates in addition to namespace names in
"using ns_name::name;".

https://wandbox.org/permlink/zG6JvMtNwxXK4yPn

////////////////////////////////////////////////////////////////////////////
#include<stdio.h>

namespace N1 {
   const char* f() {
      return "NamespaceN1::f()";
    }
}

namespace N2 {
  struct N1 {
    static const char* f() {
      return "NamespaceN2::StructN1::f()";
    }
  };
}

using namespace N2;
using N1::f;

int main()
{
    printf("%s\n", f());
    return 0;
}

////////////////////////////////////////////////////////////////////////////
Compilation Error on CLANG:

prog.cc:18:7: error: reference to 'N1' is ambiguous
using N1::f;
      ^
prog.cc:3:11: note: candidate found by name lookup is 'N1'
namespace N1 {
          ^
prog.cc:10:10: note: candidate found by name lookup is 'N2::N1'
  struct N1 {
         ^
prog.cc:22:20: error: use of undeclared identifier 'f'; did you mean 'N1::f'?
    printf("%s\n", f());
                   ^
                   N1::f
prog.cc:4:16: note: 'N1::f' declared here
   const char* f() {
               ^
2 errors generated.

////////////////////////////////////////////////////////////////////////////
Result on GCC:

NamespaceN1::f()

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200316/9a6fea6c/attachment.html>


More information about the llvm-bugs mailing list