https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104691

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The unincluded source:
#include <array>
#include <iostream>
#include <type_traits>

template <typename TContainer>
std::enable_if_t<!TContainer{}.empty(), TContainer>
MakeFilled(const typename
std::remove_reference<decltype(*TContainer{}.begin())>::type & value)
{
  TContainer result{};
  std::fill(result.begin(), result.end(), value);
  return result;
}

template <typename TContainer>
std::enable_if_t<std::is_class<typename TContainer::allocator_type>::value,
TContainer>
MakeFilled(const typename
std::remove_reference<decltype(*TContainer{}.begin())>::type & value)
{
  static_assert(false, "Substitution failure so this should never be
checked!");
}


int
main()
{
  using ArrayWithPositiveSize = std::array<int, 4>;
  ArrayWithPositiveSize a = MakeFilled<ArrayWithPositiveSize>(8);
  std::cout << "a[" << a.size() - 1 << "] = " << a[a.size() - 1] << std::endl;
}
---- CUT ----
clang also causes the assert to happen. I have not looked further into why
though.

Reply via email to