http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54648
Bug #: 54648
Summary: constexpr function rejected as non const
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
I am getting from gcc-4.8.0 20120920 for constexpr function:
error: integral expression ‘is_range<vector<int>&>()’ is not constant
With gcc-4.7.1 (and with gcc-4.8 older than a month) it compiles correctly.
This error is generated only in some particular combination of source code. I
was not able to reproduce it in minimal example. File main.ii is attached.
Function is_range is defined as:
------------------------------------------------------
template<typename T>
constexpr bool
is_range() { return is_range_t<T>::value; };
------------------------------------------------------
Type is_range_t defined as:
-----------------------------------------------------
template <typename T>
struct is_range_t {
template <
class U,
class I = typename U::const_iterator
>
static int8_t
test(U* u);
template <typename U>
static int16_t
test(...);
enum { value = sizeof test <rm_qualifier<T>> (0) == 1 };
};
template<typename T, size_t N> struct is_range_t <T[N]> : std::true_type { };
template<typename T, size_t N> struct is_range_t <T(&)[N]> : std::true_type {
};
template<typename T, size_t N> struct is_range_t <std::array<T,N>> :
std::true_type { };
template<typename T> constexpr bool is_range() { return is_range_t<T>::value;
};
-----------------------------------------------------