diff --git a/include/boost/config/compiler/clang.hpp b/include/boost/config/compiler/clang.hpp index 74073b41..b5ef4d08 100644 --- a/include/boost/config/compiler/clang.hpp +++ b/include/boost/config/compiler/clang.hpp @@ -225,7 +225,16 @@ # define BOOST_NO_CXX14_GENERIC_LAMBDAS #endif -#if !(__has_feature(cxx_relaxed_constexpr) || __has_extension(cxx_relaxed_constexpr)) +// clang < 3.5 has a defect with dependent type, like following. +// +// template +// constexpr typename enable_if >::type foo(T &) +// { } // error: no return statement in constexpr function +// +// This issue also affects C++11 mode, but C++11 constexpr requires return stmt. +// Therefore we don't care such case. +#if (__clang_major__ == 3 && __clang_minor__ < 5) \ + || !(__has_feature(cxx_relaxed_constexpr) || __has_extension(cxx_relaxed_constexpr)) # define BOOST_NO_CXX14_CONSTEXPR #endif diff --git a/test/boost_no_cxx14_constexpr.ipp b/test/boost_no_cxx14_constexpr.ipp index 1e8918bf..5dd43dfa 100644 --- a/test/boost_no_cxx14_constexpr.ipp +++ b/test/boost_no_cxx14_constexpr.ipp @@ -14,7 +14,15 @@ namespace boost_no_cxx14_constexpr { -constexpr void decrement(int &value) +namespace detail +{ + template struct void_ { typedef void type; }; +} + +// Test relaxed constexpr with dependent type; for more details, see comment of +// BOOST_CXX14_CONSTEXPR definition in boost/config/compiler/clang.hpp . +template +constexpr typename detail::void_::type decrement(T &value) { --value; }