https://llvm.org/bugs/show_bug.cgi?id=24173

            Bug ID: 24173
           Summary: Interminable compilation when using __is_constructible
                    intrinsic
           Product: clang
           Version: 3.6
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The following code causes Clang to never finish compiling, eventually 
exhausting all the memory available on my machine:

------------------------------------------------------------------------------
#include <type_traits>


#if 1
#   define IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
#else
#   define IS_CONSTRUCTIBLE(...) is_constructible<__VA_ARGS__>::value
#endif

template <typename ...T>
struct is_constructible
    : std::integral_constant<bool, __is_constructible(T...)>
{ };

template <bool ...b>
struct fast_and
    : std::is_same<fast_and<b...>, fast_and<(b, true)...>>
{ };

template <typename ...Xn>
struct closure {
    template <typename ...Yn, typename = typename std::enable_if<
        fast_and<IS_CONSTRUCTIBLE(Xn, Yn&&)...>::value
    >::type>
    explicit constexpr closure(Yn&& ...yn);

    template <typename ...Yn, typename = typename std::enable_if<
        fast_and<IS_CONSTRUCTIBLE(Xn, Yn&&)...>::value
    >::type>
    constexpr closure(closure<Yn...>&& other);
};

template <typename ...Xs>
constexpr
closure<std::decay_t<Xs>...> f(Xs&& ...xs)
{ return closure<std::decay_t<Xs>...>{static_cast<Xs&&>(xs)...}; }

int main() {
    f(f(f(f(f(f(f(f(f(f(f(f(1))))))))))));
}
------------------------------------------------------------------------------

Note that using the second definition for IS_CONSTRUCTIBLE fixes the problem.
Any clue what is happening?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to