libc++ and const expr.

Hi,

Am I the only one having trouble compiling libc++ with clang TOT.
For sometime now, clang refuse to compile (and use it) because of the following issue:

…/include/ratio:193:19: error: static_assert expression is not an integral constant expression
static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, “overflow in __ll_mul”);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
…/include/ratio:308:13: note: in instantiation of template class ‘std::__1::__ll_mul<1, 1>’ requested here
__ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
^
…/include/ratio:315:33: note: in instantiation of template class ‘std::__1::__ratio_divide<std::__1::ratio<1, 1000000000>, std::__1::ratio<1, 1000000000> >’ requested
here
template <class _R1, class _R2> using ratio_divide
^
…/include/chrono:410:18: note: in instantiation of template type alias ‘ratio_divide’ requested here
(ratio_divide<_Period2, period>::type::den == 1 &&
^
…/include/chrono:406:9: note: while substituting deduced template arguments into function template ‘duration’ [with _Rep2 = long long, _Period2 = ]
duration(const duration<_Rep2, _Period2>& __d,
^
…/include/ratio:193:26: note: initializer of ‘nan’ is not a constant expression
static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, “overflow in __ll_mul”);
^
…/include/ratio:187:27: note: declared here
static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
^
…/include/ratio:187:27: note: declared here
…/include/ratio:189:27: note: declared here
static const intmax_t max = -min;

– Jean-Daniel

I got the same thing.

-Rich

A number of things seem to have broken all at once. Commenting out that static_assert leads to a bug in src/locale.cpp about switching on '-1' on a switch on size_t in two places. Fixing that bug (by replacing -1 and -2 with (size_t)-1 and (size_t)-2, which is hopefully right.

Fixing that leads to lining producing:

ld: bad codegen, pointer diff in __ZSt17__throw_bad_allocv to global weak symbol __ZTISt9bad_alloc for architecture i386

Rather than try to debug this myself, I'm tempted to leave it to more experienced people.

One problem that this has shown me is that the recommended way of building libcxx (symlinking the svn directories into /usr/include and /usr/lib) means that if you svn update the library and it won't build, you are left with a totally non-functional library.

Chris