1// { dg-do compile } 2// { dg-options "-O2 -fstrict-aliasing -fdump-tree-optimized" } 3 4// Test that placement new does not introduce an unnecessary memory 5// barrier. 6// See PR 29286. 7 8typedef __SIZE_TYPE__ size_t; 9 10inline void* operator new(size_t, void* __p) throw() { return __p; } 11 12template <class T, int D> 13class Vector 14{ 15public: 16 Vector() 17 { 18 for (int i = 0; i < D; ++i) 19 new (&x_m[i]) T(); 20 } 21 T& operator[](int i) { return x_m[i]; } 22 23private: 24 T x_m[D]; 25}; 26 27void foo(Vector<float, 3> *m) 28{ 29 Vector<float, 3> v; 30 v[0] = 1.0; 31 v[1] = 2.0; 32 v[3] = 3.0; 33 *m = v; 34} 35 36// { dg-final { scan-tree-dump-times "= 0\.0" 1 "optimized" } } 37// { dg-final { cleanup-tree-dump "optimized" } } 38