[cfe-dev] Visual Studio 9 2008 compile error in ASTContext.cpp

Stephan T. Lavavej stl at exchange.microsoft.com
Wed Jun 20 16:49:10 PDT 2012


[Manjunath Kudlur]
> I am getting the following error when compiling clang with Visual Studio 9 2008 (cmake -G "Visual Studio 9 2008").

clang is invoking lower_bound() with a heterogeneous comparison - the provided value is of a different type than the elements.  VC8 and VC9 have debug checks that perform homogenous comparisons (to ensure that the input range is actually sorted), so you get a compiler error if homogeneous comparisons aren't available.  Technically, this behavior was conformant according to C++03.

C++11's requirements were relaxed, permitting heterogeneous comparisons.  Accordingly, we commented out lower_bound and upper_bound's debug checks (as an aside, we forgot equal_range, oops - this is on my todo list).  So VC10+ will work here.

Even though you should *really* upgrade, there are a couple of workarounds for VC9.  You could disable the debug checks, although if you're not careful this will explode horribly.  To do this, define _HAS_ITERATOR_DEBUGGING to 0 globally (ideally, on the command line).  Alternatively, if the element type and the value type have the "same ordering", then a source workaround is to have the comparator also provide the (ElementType, ElementType) comparison that the debug checks want.

Stephan T. Lavavej
Visual C++ Libraries Developer






More information about the cfe-dev mailing list