| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3" } */ |
| 3 |
|
| 4 |
void __throw_out_of_range_fmt(...); |
| 5 |
char *_M_p; |
| 6 |
struct Trans_NS___cxx11_basic_string { |
| 7 |
long _M_string_length; |
| 8 |
long _M_check___pos; |
| 9 |
Trans_NS___cxx11_basic_string() { |
| 10 |
long __length = 0; |
| 11 |
_M_string_length = __length; |
| 12 |
} |
| 13 |
long size() { return _M_string_length; } |
| 14 |
long foo___pos; |
| 15 |
char foo() { return _M_p[foo___pos]; } |
| 16 |
int compare() { __throw_out_of_range_fmt(_M_check___pos, _M_string_length); __builtin_trap(); } |
| 17 |
}; |
| 18 |
bool str_starts_with(Trans_NS___cxx11_basic_string &str, |
| 19 |
Trans_NS___cxx11_basic_string prefix) { |
| 20 |
if (str.size() < prefix.size()) |
| 21 |
str.compare(); |
| 22 |
for (; prefix.size();) { |
| 23 |
char __trans_tmp_2 = prefix.foo(); |
| 24 |
if (__trans_tmp_2) |
| 25 |
return false; |
| 26 |
} |
| 27 |
__builtin_trap(); |
| 28 |
} |
| 29 |
void testStartsWith() { |
| 30 |
Trans_NS___cxx11_basic_string s1, s2; |
| 31 |
str_starts_with(s1, s2); |
| 32 |
} |