Arcoth/Constainer

GCC fails Array comparison testcase

Closed this issue · 1 comments

constexpr Array<int, 10> a {{1, 2, 3, 4, 5}};
constexpr Array<int, 10> a2{{1, 2, 3, 4, 5}};
static_assert( a == a2 );

Fails with GCC trunk 20150813:

Constainer/Testing.cxx:23:1: error: non-constant condition for static assertion
 static_assert( a == a2 );
 ^
In file included from Constainer/impl/../Array.hxx:7:0,
                 from Constainer/impl/BasicVector.hxx:7,
                 from Constainer/String.hxx:8,
                 from Constainer/Parser.hxx:7,
                 from Constainer/Testing.cxx:7:
Constainer/Testing.cxx:23:18:   in constexpr expansion of ‘Constainer::operator==<int, 10ul, int, 10ul>(a, a2)’
Constainer/impl/../Array.hxx:89:14:   in constexpr expansion of ‘Constainer::equal<const int*, const int*>((& lhs)->Constainer::Array<T, Size>::begin<int, 10ul>(), (& lhs)->Constainer::Array<T, Size>::end<int, 10ul>(), (& rhs)->Constainer::Array<T, Size>::begin<int, 10ul>(), (& rhs)->Constainer::Array<T, Size>::end<int, 10ul>())’
Constainer/impl/../Algorithms.hxx:269:26:   in constexpr expansion of ‘Constainer::equal<const int*, const int*, std::equal_to<void> >(first1, last1, first2, last2, (std::equal_to<void>(), std::equal_to<void>()))’
Constainer/impl/../Algorithms.hxx:264:31:   in constexpr expansion of ‘Constainer::mismatch<const int*, const int*, std::equal_to<void> >(first1, last1, first2, last2, (comp, std::equal_to<void>()))’
Constainer/impl/../Algorithms.hxx:220:2: error: ‘(((const int*)(& a.Constainer::Array<int, 10ul>::_storage)) == (((const int*)(& a.Constainer::Array<int, 10ul>::_storage)) + 40u))’ is not a constant expression
  while (first1 != last1 && first2 != last2) {
  ^

Reduces to

struct A {int arr[3] {1, 2, 3};} constexpr a{};
static_assert( a.arr != a.arr+3 );

Reported as #67380, dup of #67376.

#67376 has been fixed in r234698.