[LLVMbugs] [Bug 19894] New: Can't pass ref-qualified function types to typeid, unless you do it in a template

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 29 15:43:01 PDT 2014


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

            Bug ID: 19894
           Summary: Can't pass ref-qualified function types to typeid,
                    unless you do it in a template
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mclow.lists at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider the following code:

template <class _Tp> struct split { typedef _Tp ptr; };
template <class _Tp, class _Up> struct split<_Tp _Up::*> { typedef _Tp ptr;
typedef _Up base; };

struct X {};
typedef split<void (X::*)() const>::ptr  PMF;

#include <iostream>
#include <typeinfo>

template <typename T>
void print () { std::cout << typeid(T).name() << std::endl; }

int main () {
#ifdef FOO
     std::cout << typeid(PMF).name() << std::endl; 
#else
    print<PMF>();
#endif
    }

If you compile with clang++ -std=c++11 -DFOO, you get a compile error:
junk4.cpp:20:23: error: non-member function of type 'PMF' (aka 'void () const')
cannot have 'const' qualifier
        std::cout << typeid(PMF).name() << std::endl; 

but if you don't -DFOO, it compiles w/o error and prints: "KFvvE", which
demangles to "void () const".

Expectation: Either you should be able to pass this type to typeid() or not.
Washing it through a template should not "make it work".

-- 
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/20140529/b8a6da1c/attachment.html>


More information about the llvm-bugs mailing list