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