[cfe-dev] MS/Borland portability and 2-phase lookup

Bo Persson bop at gmb.dk
Fri Mar 4 02:00:42 PST 2011




On 4 mar 2011 09:31 "John McCall" <rjmccall at apple.com> wrote:
> On Mar 4, 2011, at 12:08 AM, Eric Niebler wrote:
> > We have a portability problem compiling old code for MS/Borland with
> > clang: 2-phase lookup. Those compilers don't do it, so they accept
> > code
> > that clang rejects. For example:
> > 
> > template<class X>
> > struct S {
> >  int i;
> > };
> > 
> > template<class Y>
> > struct T {
> >  T() {
> >    i = 0; // ERROR, should be T::i or this->i
> >  }
> > };
> > 
> > Clang correctly diagnoses this problem, which presents a problem for
> > old
> > broken code that compiles OK with MS and Borland. This problem
> > appears
> > to be quite widespread.
> > 
> > Would there be any interest in a patch that turns off 2-phase
> > lookup
> > when in MS/Borland compatibility mode
> > (-fms-extensions/-fborland-extensions)? If so, I can see about
> > providing
> > one.
> 
> I think François Pichet is working on an MS-compatible template
> mechanism.
> It's more complicated than just turning off 2-phase lookup.
> 

It would also be nice to have a finer grained control than enabling ALL bugs for particular compiler. In your example it might be better to actually fix the code, rather than have the compiler accept everything.


Bo Persson




More information about the cfe-dev mailing list