!- compilation of WTL example WTL/MDIDocVw fails with clang. MS can compile the whole project without any errors. These problems also appear during compilation of this sample: 26735 26748 -! ========Environment============== Os: Win Language: C++ Version: trunk ========Reproducer================ 1) Download WTL from here: https://sourceforge.net/projects/wtl/ to [WTL_HOME] 2) Goto [WTL_HOME]/Samples/MDIDocVw 3) clang-cl -c -D "_UNICODE" -D "UNICODE" -I ../../include -w MDI.cpp ========Small Reproducer========== /*code from include/atlframe.h*/ template <class T> class CUpdateUI { public: CUpdateUI() { T* pT = static_cast<T*>(this); } }; /*code from sample WTL/MDIDocVw (mainfrm.h )*/ class CMDIFrame : CUpdateUI<CMDIFrame> { public: virtual int DoUpdate() { return 0; } }; /* default constructor is called in MDI.cpp*/ int main (){ CMDIFrame wndMain; return 0; } =============Error================== >>> clang: error: cannot cast private base class 'CUpdateUI<CMDIFrame>' to 'CMDIFrame' T* pT = static_cast<T*>(this); ^ note: in instantiation of member function 'CUpdateUI<CMDIFrame>::CUpdateUI' requested here class CMDIFrame : CUpdateUI<CMDIFrame> ^ note: implicitly declared private here class CMDIFrame : CUpdateUI<CMDIFrame> ^~~~~~~~~~~~~~~~~~~~ >>> msvc: no diag >>> gcc: error: ‘CUpdateUI<CMDIFrame>’ is an inaccessible base of ‘CMDIFrame’ T* pT = static_cast<T*>(this); Andrey Kuleshov ====== Software Engineer Intel Compiler Team
The code is obviously ill-formed; the question is, does it make sense for us to be compatible with this MSVC bug? If this only occurs in sample code, that doesn't seem like a very compelling case to me. If this also occurs in a large quantity of real code derived from those samples, that would be more persuasive.
Also, have you contacted the authors of this code to let them know their samples are broken?
(In reply to comment #2) > Also, have you contacted the authors of this code to let them know their > samples are broken? Actually not, I just wanted to know whether clang can compile WTL/ATL headers. And the only way to check templates was to compile samples where they have instantiation. Probably after a check of all samples I will report such problems to authors. (In reply to comment #1) > The code is obviously ill-formed; the question is, does it make sense for us > to be compatible with this MSVC bug? > > If this only occurs in sample code, that doesn't seem like a very compelling > case to me. If this also occurs in a large quantity of real code derived > from those samples, that would be more persuasive. Yes, I understand that such code has no sense and I'm ok with closing PR as Resolved Invalid. But anyway I wanted to report that there is ms bug that allows users to compile code from real samples that clang is not able to compile. I've checked a half of samples that are in WTL and this problem appears only in this one sample.
Fixed by http://reviews.llvm.org/D19477
Reverted by r267865.