1 // PR c++/53792
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fdump-tree-optimized" }
4 // { dg-final { scan-tree-dump "return 0" "optimized" } }
5 
6 struct entry {
foo()7   char const* label;
bar()8   int         value;
9 };
10 
11 constexpr bool same(char const *x, char const *y) {
12   return !*x && !*y ? true
13     : /* default */    (*x == *y && same(x+1, y+1));
14 }
15 
16 constexpr int keyToValue(char const *label, entry const *entries) {
17   return !entries->label ? entries->value
18        : same(entries->label, label) ? entries->value
19        : /*default*/                   keyToValue(label, entries+1);
20 }
21 
22 constexpr entry foo[] = {{"Foo", 0}, {"Bar", 1}, {"FooBar", 2}, {0, -1}};
23 
24 int
25 bar()
26 {
27   int result = keyToValue("Foo", foo);
28   return result;
29 }
30