Q:

arrays overlapping in a union?

I have this class:
template <typename T, ::std::size_t M, ::std::size_t N>
struct matrix
{
private:
  union
  {
    T idata[M * N];
    T data[M][N];
  } u_;
};

I use the idata union member to initialize the matrix and the data member for access. The two arrays seem to overlap exactly in my use-case. Does the standard guarantee that this will always be the case? That is, that both u_.idata and u_.data will have the same starting address and the same size?
EDIT:
I use this constexpr constructor to initialize the matrix:
template <typename ...U>
constexpr matrix(U&&... args) : u_{{::std::forward<U>(args)...}}
{
}

Without the union I would have no way to initialize the matrix in a constexpr constructor.

A:

Without the union I would have no way to initialize the matrix in a constexpr constructor.

Actually, you could.  You just have to stop thinking of the flat array as merely a workaround for construction.
This will work:
template <typename T, ::std::size_t M, ::std::size_t N>
struct matrix
{
  template <typename ...U> constexpr matrix(U&&... args);
private:
  T idata[M * N];
  constexpr T& data( size_t i, size_t j ) { return idata[i*N+j]; }

  // I'm sure the class has many other useful members but I'm not listing them
};

The compiler should generate the same code for that, too.

