<div dir="ltr">On Thu, Jul 4, 2013 at 12:48 AM, Benoit Perrot <span dir="ltr"><<a href="mailto:benoit.noe.perrot@gmail.com" target="_blank">benoit.noe.perrot@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hello,</div></div></blockquote><div><br>

</div><div>Hi Benoit,</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>

I have just updated my svn copy of the llvm/clang repositories after quite a long time of inactivity, and found it not compiling on Windows with Visual Studio 2008.</div>
<div><br></div><div>The incriminated file is:</div><div><br></div><div>  llvm/lib/MC/MCModule.cpp</div><div><br></div><div>Where several calls to "std::lower_bound" are made, like:</div><div><br></div><div>  atom_iterator I = std::lower_bound(atom_begin(), atom_end(),</div>


<div>                                     Begin, AtomComp);</div><div><br></div><div>With:</div><div>  - "atom_iterator" being a typedef on "std::vector<llvm::Atom*>::iterator"</div><div>  - "atom_begin()" and "atom_end" returning an "atom_iterator"</div>


<div>  - "Begin" being an "uint64_t"</div><div>  - "AtomComp" being a predicate of type "bool (const llvm::MCAtom *,uint64_t)"</div><div><br></div><div>This seems to be due to an invalid implementation of the STL as provided with Visual Studio 2008.</div>


<div><br></div><div>Indeed, the predicate given to "lower_bound" must respect the following rules:</div><div><br></div><div>  - obviously, it shall return "bool" (here: of course)</div><div><br></div>

<div>
  - its first argument shall be of a type into which the type of the dereferenced iterators can be implicitly converted (here: "atom_iterator::operator*" returns a "llvm::Atom*", and the first argument of "AtomComp" is also "llvm::Atom*"</div>


<div><br></div><div>  - its second argument shall be of a type into which the type of the value can be implicitly converted (here: "Begin" is an "uint_64_t", as well as the second argument of "AtomComp")</div>


<div>    </div><div>But the implementation of "std::lower_bound" in Visual Stuio 2008 relies on a checker provided by the file "xutility", which reads:</div><div><br></div><div>template<class _Pr, class _Ty1, class _Ty2> inline</div>


<div>bool __CLRCALL_OR_CDECL _Debug_lt_pred(_Pr _Pred,</div><div>                                       _Ty1& _Left,</div><div>                                       const _Ty2& _Right,</div><div>                                       const wchar_t *_Where,</div>


<div>                                       unsigned int _Line)</div><div>{<span style="white-space:pre-wrap">        </span>// test if _Pred(_Left, _Right) and _Pred is strict weak ordering</div><div><br></div><div>  if (!_Pred(_Left, _Right))</div>


<div>    return (false);</div><div>  else if (_Pred(_Right, _Left))</div><div>    _DEBUG_ERROR2("invalid operator<", _Where, _Line);</div><div><br></div><div>  return (true);</div><div>}</div><div><br></div>

<div>
Hence, it expects the predicate (here "_Pred") to accept as arguments both (_Ty1, _Ty2) and (_Ty2, _Ty1), which does not seem consistent with the specifications mentioned above.</div><div><br></div><div>Solutions here:</div>


<div><br></div><div>1. consider that the implementation if effectively wrong, and modify the documentation at <a href="http://llvm.org/docs/GettingStartedVS.html" target="_blank">http://llvm.org/docs/GettingStartedVS.html</a>, requiring Visual Studio 2010, i.e. replacing:</div>


<div><br></div><div>   "You will need Visual Studio 2008 or higher."</div><div><br></div><div>   by:</div><div><br></div><div>   "You will need Visual Studio 2010 or higher."</div><div><br></div><div>

   Same comments on the respect of the standard apply</div>
<div><br></div><div>2. investigate whether there exists a way to disable the aforementioned check;</div><div><br></div><div>3. modify the code in MCModule.cpp to cope with the implementation of "lower_bound" in VS 2008.</div>


<div><br></div><div>Personally I just went for (1), i.e. switching to Visual Studio 2010, as it was the most straightforward.</div></div></blockquote><div><br></div><div>(3) Fixed in r185676.</div><div><br></div><div>Requiring VS 2010 for a minor problem like this (even though there are more like it) isn’t warranted I think.</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Doing so, I also had to add "#include <string>" to the file "lib/CodeGen/CGBlocks.cpp" so that llvm/clang can compile with said compiler, because of some obscure external template usage.</div>

</div></blockquote><div><br></div><div><string> is already included, at least by StringRef.h, so I’m curious: what is this obscure thing that needs including it again?</div><div><br></div><div>Thanks,</div><div><br>

</div><div><div>-- Ahmed Bougacha</div></div><div>  <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div></div><div>Regards,</div><span class=""><font color="#888888"><div>-- </div><div>Benoit PERROT</div><div><br></div></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>