Compile errors with MSVC 2005 (SVN revision 53516)

Hello,

Compiling SVN revision 53516 with MSVC 2005 results in many compile errors similar to this one:

Hello,

Compiling SVN revision 53516 with MSVC 2005 results in many compile
errors similar to this one:
[...]
I'm using the llvm/win32/clang.sln project to build clang. Is this the
correct way to do so?

Yes, but llvm is broken for VC2005 it seems.

In llvm/adt/alist.h:
There is two constructor and in some case VS complain

  alist_iterator(NodeIterT NI) : NodeIter(NI) {}
  alist_iterator(pointer EP) : NodeIter(NodeTy::getNode(EP)) {}

at first I was thinking it was because NodeIterT and pointer resolved to the
same type but doing some metaprogramming to remove one of the constructor in
this special case don't seems to work. In fact it seems they never are the
same type. So I don't understand what is the problem. And the error message
don't have the type nor the position of the instantiation error... really
strange.

I suppose you can try to revert llvm to previous 53209 (53210 added the file
on july, 8th), it should/may work. It seems Ted Kremenek compiled it ok with
one unknow version of VS. Ted? Was is VS2008 or VS2005sp1 or has it been
broken since rev53432?

Regards,

Cédric

I've seen this problem as well. I encountered a series of VC++ errors with alist and ilist with regards to typedefs being private (and fixed those), but I hit this same problem and was still in the process of diagnosing it. I didn't have a chance to dive into this further on Friday or today because I am away from a Windows machine. I am using VS 2005.

FWIW, VC++ has far more limited template support than GCC does. When I was writing the serialization library (for generic object serialization; this is used in Clang), I had to be careful of the use of things like member templates in templated classes because I would hit weird limitations with VC++. It's entirely possible that parts of alist need to be rewritten in order for it to work on VC++.

The changes to (or rather the creation of) alist I think are very recent (I believe this is Dan Gohman's work). I've CC'ed him on this message in case he has any ideas of what an easy fix would be, since he's the one most familiar with that code.

If you change

  alist_iterator(pointer EP) : NodeIter(NodeTy::getNode(EP)) {}

to

  alist_iterator(ValueT *EP) : NodeIter(NodeTy::getNode(EP)) {}

It will compile fine.
Not sure if this is definitely the right fix, though...

-Argiris

If you change

  alist_iterator(pointer EP) : NodeIter(NodeTy::getNode(EP)) {}

to

  alist_iterator(ValueT *EP) : NodeIter(NodeTy::getNode(EP)) {}

It will compile fine.

Yes, I just changed
  typedef typename super::pointer pointer;
to
  typedef ValueT* pointer;

and it work. Before it was referring to
  bidirectional_iterator<ValueT, ptrdiff_t>::pointer
which is
  std::iterator<std::bidirectional_iterator_tag, Ty,

::pointer

which with the STL of VC++2005 is
  template<class _Category,
  class _Ty,
  class _Diff = ptrdiff_t,
  class _Pointer = _Ty *,
  class _Reference = _Ty&>
    struct iterator
      : public _Iterator_base

  { // base type for all iterator classes
  typedef _Category iterator_category;
  typedef _Ty value_type;
  typedef _Diff difference_type;
  typedef _Diff distance_type; // retained
  typedef _Pointer pointer;
  typedef _Reference reference;
  };

So it is just doing manually what the compiler should do.

I don't think this will break with any existing STL implementation, someone
should commit a patch at least as temporary fix.

Incidentally, does the following work:

change:

   typedef typename super::pointer pointer;
   typedef typename super::reference reference;

to:

   typedef typename bidirectional_iterator<ValueT, ptrdiff_t>::pointer pointer
   typedef typename bidirectional_iterator<ValueT, ptrdiff_t>::reference reference

If that worked, it would obviate the need to make an assumption on how bidirectional_iterator defines "pointer" and "reference".

change:

   typedef typename super::pointer pointer;

to:

   typedef typename bidirectional_iterator<ValueT, ptrdiff_t>::pointer
pointer

This does not work, I tried it first. Even when I modify
bidirectional_iterator by adding a public typedef to
std::iterator<>::pointer directly in the class...

On the other hand I remember reading that the way the std::allocator is
defined in C++03, you don't have much choice for defining pointer.

I've applied this patch. Hopefully we can find a better workaround. This solution also only goes half way (what to do about "reference"?).

Hello,

Ted Kremenek wrote:

remove_machine_debug.diff (423 Bytes)

add_files.diff (673 Bytes)

I checked with Cedric and he committed the appropriate fix. Apparently cfe-commits is having problems, as I couldn't tell that the patch was applied until doing an svn update.