It looks to me like the problem is due to a template implementation not being visible to the code being compiled. GCC and VC++ don't enforce the C++ standard strictly here, and the CodeWarrior and EDG-based compilers correctly flag this as invalid code. VC++ compiles templates by essentially converting the entire declaration into a macro which gets expanded only at the final front-end compilation stage, and thus it doesn't templated code until later (which in fact the templated type has become fully visible). GCC is somewhat like VC++ but seems to do a certain amount of first-pass inspection of the template declaration that catches some misusage within the template declaration itself, but it still doesn't check or compile the template code upon its usage like CodeWarrior and GCC do. The fix is to make the template declaration (as opposed to a forward declaration) fully visible at the time of its usage.

I'm saying this based on experience and not because I have debugged this particular problem myself. So it could possibly be a different issue. But the error messages below, and the fact that it is occurring with EDG and not GCC and VC++, and because it involves templates rings all the bells of this problem.

There is a related C++ problem which is more subtle. Consider this code that the compiler sees in the given order:

    1) Declare template X
    2) Use template X
    3) Declare specialization of template X

Most compilers incorrectly compile the specialization (line 3) into the usage at line 2. But the standard requires that the specialization be ignored, since it was not visible at the time line 2 was compiled. You can see why it is that a compiler which treats templates much like macros will get this wrong, as they don't compile line 2 until later and simply apply both the 'macros' declared at line 1 and 3.

Paul


Hi Webkit Forum,

I am getting compilation errors while compiling webcore and _javascript_core with ARM RVCT compiler version 2.2 build 559. This is my maiden attempt to build webkit with RVCT compiler.
Three errors are appearing while compiling many source files. I have provided Attr.cpp as an example compilation.
When compiling k:\webkit/webcore/dom/Attr.cpp following 3 errors are displayed
1) "E:\WebKit\CygWin\home\output\include/_javascript_Core/PassRefPtr.h", line 44: Error:  #393: pointer ptr to incomplete class type is not allowed ALWAYS_INLINE ~PassRefPtr() { if (T* ptr = m_ptr) ptr->deref(); }
                                                                                        ^
2) "E:\WebKit\CygWin\home\output\include/_javascript_Core/ListHashSet.h", line 445: Error:  #254: typename is not allowed
          typename ImplType::iterator it = m_impl.template find<ValueType, Translator>(value);
          ^
3) "E:\WebKit\CygWin\home\output\include/_javascript_Core/RefPtr.h", line 58: Error:  #20: identifier "adoptRef" is undefined
          PassRefPtr<T> release() { PassRefPtr<T> tmp = adoptRef(m_ptr); m_ptr = 0; return tmp; }
                                                                                  ^
Please help to resolve this problem.

Regards,
Shaddu

_______________________________________________ webkit-dev mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev



_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to