https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98216
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: template<typename T, int N> struct array { constexpr T& operator[](int n) { return d[n]; } constexpr const T& operator[](int n) const { return d[n]; } constexpr bool operator==(const array& a) const { for (int i = 0; i < N; ++i) if (d[i] != a.d[i]) return false; return true; } T d[N]; }; using an_array = array <double, 1>; constexpr auto add_array (an_array a, an_array const& b) { a[0] += b[0]; return a; } template <an_array A> struct wrapper { static constexpr auto arr = A; }; template <an_array A1 , an_array A2> auto add (wrapper <A1> const&, wrapper <A2> const&) { return wrapper <add_array (A1, A2)> {}; } constexpr auto ONE = an_array {{ 1. }}; constexpr auto MINUS_ONE = an_array {{ -1. }}; constexpr auto MINUS_TWO = an_array {{ -2. }}; int main () { auto a = wrapper <MINUS_TWO> {}; auto b = wrapper <ONE> {}; auto c = add (a, b); __builtin_printf("%f %f %f\n", a.arr[0], b.arr[0], c.arr[0]); if (c.arr != MINUS_ONE) __builtin_abort(); } Prints: -2.000000 1.000000 -2.000000 Aborted (core dumped)