LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27337 - [ms] clang-cl fails to compile sample MDIDocVw from WTL (header atlframe.h)
Summary: [ms] clang-cl fails to compile sample MDIDocVw from WTL (header atlframe.h)
Status: RESOLVED WONTFIX
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Dmitry Polukhin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-13 08:02 PDT by Andrey Kuleshov
Modified: 2018-11-07 00:21 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Kuleshov 2016-04-13 08:02:26 PDT
!- 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
Comment 1 Richard Smith 2016-04-13 19:18:53 PDT
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.
Comment 2 Richard Smith 2016-04-13 19:20:00 PDT
Also, have you contacted the authors of this code to let them know their samples are broken?
Comment 3 Andrey Kuleshov 2016-04-14 02:42:39 PDT
(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.
Comment 4 Dmitry Polukhin 2016-04-26 04:26:04 PDT
Fixed by http://reviews.llvm.org/D19477
Comment 5 Dmitry Polukhin 2016-04-28 07:23:55 PDT
Reverted by r267865.