From 32ecea81e0ae8d4bab89f9dbe687ddd03905b472 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 7 Nov 2018 13:52:52 +0000 Subject: [PATCH 1/2] Add test case for issue #246 --- test/boost_no_constexpr.ipp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/boost_no_constexpr.ipp b/test/boost_no_constexpr.ipp index 35ac4891..1f3a96ee 100644 --- a/test/boost_no_constexpr.ipp +++ b/test/boost_no_constexpr.ipp @@ -32,13 +32,7 @@ private: template struct X { }; - -#if __cplusplus < 201400L -// Some C++14 compilers reject this (clang), some C++11 compilers reject "constexpr const" (GCC-4.6) -constexpr A a = 42; -#else constexpr const A a = 42; -#endif X xx; // OK: unique conversion to int @@ -68,9 +62,18 @@ struct F : virtual E }; constexpr F& f(F& out) { return out; } +namespace whatever{}; + +constexpr int factorial(int i) +{ + typedef int value_type; + using namespace whatever; + return i <= 1 ? 1 : i * factorial(value_type(i-1)); +} + int test() { - int i = square(5); + constexpr int i = square(5) + factorial(10); quiet_warning(i); switch (i) From f48077f631f981ddfa1f4aea35e128decd1f57e5 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 7 Nov 2018 18:12:32 +0000 Subject: [PATCH 2/2] Make constexpr a gcc-4.7 feature not 4.6. --- include/boost/config/compiler/gcc.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/config/compiler/gcc.hpp b/include/boost/config/compiler/gcc.hpp index 594c44f5..9ae6072e 100644 --- a/include/boost/config/compiler/gcc.hpp +++ b/include/boost/config/compiler/gcc.hpp @@ -232,7 +232,6 @@ // C++0x features in 4.6.n and later // #if (BOOST_GCC_VERSION < 40600) || !defined(BOOST_GCC_CXX11) -#define BOOST_NO_CXX11_CONSTEXPR #define BOOST_NO_CXX11_DEFAULTED_MOVES #define BOOST_NO_CXX11_NOEXCEPT #define BOOST_NO_CXX11_NULLPTR @@ -243,6 +242,9 @@ // C++0x features in 4.7.n and later // #if (BOOST_GCC_VERSION < 40700) || !defined(BOOST_GCC_CXX11) +// Note that while constexpr is partly supported in gcc-4.6 it's a +// pre-std version with several bugs: +# define BOOST_NO_CXX11_CONSTEXPR # define BOOST_NO_CXX11_FINAL # define BOOST_NO_CXX11_TEMPLATE_ALIASES # define BOOST_NO_CXX11_USER_DEFINED_LITERALS