[LLVMbugs] [Bug 7244] New: Compilation error while using forward declared class in template function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 28 05:32:35 PDT 2010


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

           Summary: Compilation error while using forward declared class
                    in template function
           Product: clang
           Version: unspecified
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ogoffart at kde.org
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


// Extracted from webkit
struct JSCell {};

struct JSValue {
    JSValue(JSCell *) {}
};

struct JSNode;

template<class WrapperClass> inline JSValue getDOMNodeWrapper(JSNode* wrapper)
{
    return wrapper;
}

struct JSNode : JSCell {};

int main()
{
    getDOMNodeWrapper<int>(0);
    return 0;
}

/*
test.cpp:12:12: error: no viable conversion from 'JSNode *' to 'JSValue'
    return wrapper;
           ^~~~~~~
test.cpp:4:8: note: candidate constructor (the implicit copy constructor) not
viable: cannot convert argument of incomplete type 'JSNode *' to 'JSValue const
&'
struct JSValue {
       ^
test.cpp:5:5: note: candidate constructor not viable: cannot convert argument
of incomplete type 'JSNode *' to 'JSCell *'
    JSValue(JSCell *) {}
    ^
1 error generated.
*/

GCC compiles this code fine.
But I think this might be a bug in GCC. In that case, WebKit would need to be
fixed instead.

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