[LLVMbugs] [Bug 14402] New: incorrect "self" for child class of nested class in template class

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 21 11:49:35 PST 2012


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

             Bug #: 14402
           Summary: incorrect "self" for child class of nested class in
                    template class
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ryan at igglybob.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9581
  --> http://llvm.org/bugs/attachment.cgi?id=9581
reduction of problem to simple test case

The attached file causes the following error:

----
/home/ryan/test.cpp:20:16: error: call to non-static member function 'm' of 'A'
from nested type 'C'
    void x() { m(); }
               ^
1 error generated.
----

GCC does not generate this error and I don't believe it to be correct.  The
problem can be worked around by calling '(*this).m()' instead of 'm()'. 
Without knowing the internals of clang and having slept through my compilers
class (which led to some odd dreams), my three-miles-high assumption is that
the compiler is not properly realizing that it is inside of a child class.

By commenting out the 'template<typename T>' at the top of the definition of
class A, the error does not appear (although you will also have to uncomment
the relevant portions in main()).

I tested the problem on clang 3.1-8 and then compiled from trunk and also
reproduced the behavior there.

It is possible I misunderstood the C++ language spec and this is actually
intended behavior, but that doesn't seem quite right to me.

-- 
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