[LLVMbugs] [Bug 8792] New: using namespace creates ambiguity when there isn't.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 14 22:11:50 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8792

           Summary: using namespace creates ambiguity when there isn't.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: scoopr at iki.fi
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Following test-case compiles on gcc, but doesn't on clang (r121362)



namespace foo {
    struct B {
        int i;
    };    
}

namespace bar {
    struct B {
        int i;
    };        
}


using namespace foo;
using namespace bar;

class A {
protected:

    struct B {
        float f;
    };


    struct C {
        B b;
        void foo() { b.f = 0; }
    };


};




clang says:
t.cpp:28:9: error: reference to 'B' is ambiguous
        B b;
        ^
t.cpp:4:12: note: candidate found by name lookup is 'foo::B'
    struct B {
           ^
t.cpp:10:12: note: candidate found by name lookup is 'bar::B'
    struct B {
           ^
t.cpp:29:24: error: no member named 'f' in 'foo::B'
        void foo() { b.f = 0; }
                     ~ ^
2 errors generated.


So, it forgets about the inner B when same-named struct are brought in with
'using namespace'

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list