3 // Test the problematic cases identified in PR libstdc++/109150
4 // where the previous std::fill was non-conforming.
7 #include <testsuite_hooks.h>
12 void operator=(const int& i
) { VERIFY(&i
== &global
); }
16 test_identity_matters()
19 // Assigning int to X has non-trivial side effects, so we cannot
20 // hoist the load outside the loop, we have to do exactly what the
21 // standard says to do.
22 std::fill(&x
, &x
+1, global
);
27 void operator=(int ii
) { i
= ii
+ 1; }
34 // Assigning int to X has non-trivial side effects, altering the value
35 // used to fill the later elements. Must not load it outside the loop.
36 std::fill(y
, y
+2, y
[0].i
);
43 #if __cplusplus >= 201103L
44 explicit Z(const Z
&) = default;
49 test_explicit_copy_ctor()
52 // The optimization that copies the fill value must use direct-initialization
53 // otherwise this case would be ill-formed due to the explicit constructor.
59 test_identity_matters();
61 test_explicit_copy_ctor();