[LLVMbugs] [Bug 14525] New: Failed template instantiation with const object and const member function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 6 11:36:34 PST 2012


             Bug #: 14525
           Summary: Failed template instantiation with const object and
                    const member function
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: john.duncan at oracle.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 9647
  --> http://llvm.org/bugs/attachment.cgi?id=9647
complete example

I am reporting this against:

Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)

In the snippet below, clang compiles the nonConst wrapper but not the const

int nonConstMethod_wrapper(int i) {
    typedef NativeMethodCall_1_<int, API, int> NCALL;

    NCALL ncall(& API::nonConstMethod);
    return ncall.stub(i);

int ConstMethod_wrapper(int i) { 
    typedef NativeMethodCall_1_<int, const API, int> NCALL;

    NCALL ncall(& API::constMethod);
    return ncall.stub(i);

For a full example, compiling the attached file fails with:

template-example.cc:43:8: error: no matching constructor for initialization of
'NCALL' (aka
      'NativeMethodCall_1_<int, const API, int>')
        NCALL ncall(& API::constMethod);
              ^     ~~~~~~~~~~~~~~~~~~
template-example.cc:16:7: note: candidate constructor (the implicit copy
constructor) not viable: no known
      conversion from 'int (API::*)(int) const' to 'const
NativeMethodCall_1_<int, const API, int>' for 1st
class NativeMethodCall_1_ 
template-example.cc:24:3: note: candidate constructor not viable: no known
conversion from
      'int (API::*)(int) const' to 'Method_T' (aka 'int (const API::*)(int)')
for 1st argument;
  NativeMethodCall_1_<R, C, A0>(Method_T m) :

In my very small team, we believe the standard allows both wrappers, and our
experience is that both gcc and Visual Studio support them.  (Sun Studio 12
does not, but we've filed a bug with them, too).

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