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

            Bug ID: 86049
           Summary: Array bindings are not const when initializer is
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blitzrakete at gmail dot com
  Target Milestone: ---

Compiles with clang, doesn't under gcc 8.1.0:

template <typename, typename> struct is_same {
  static constexpr bool value = false;
};
template <typename T> struct is_same<T, T> {
  static constexpr bool value = true;
};

int main() {
  const int Array[] = {1};
  auto[One] = Array;
  static_assert(is_same<decltype(One), const int>::value); // fail
}

[dcl.struct.bind]p1 is pretty clear here that the type of the underlying
structured binding element is const int[1], and so per [dcl.struct.bind]p2 the
element type is const int and thus so is also One's type.

Reply via email to