1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 
4 #include <string>
5 
comp_test_write()6 std::string __attribute__ ((noinline)) comp_test_write() {
7   std::string data;
8 
9   for (int i = 0; i < 2; ++i) {
10     char b = 1 >> (i * 8);
11     data.append(&b, 1);
12   }
13 
14   return data;
15 }
16 
comp_test_write_good()17 std::string __attribute__ ((noinline)) comp_test_write_good() {
18   std::string data;
19 
20   char b;
21   for (int i = 0; i < 2; ++i) {
22     b = 1 >> (i * 8);
23     data.append(&b, 1);
24   }
25 
26   return data;
27 }
28 
main()29 int main() {
30   std::string good = comp_test_write_good();
31   std::string bad = comp_test_write();
32 
33   if (good != bad)
34     __builtin_abort ();
35 }
36