| 1 |
// { dg-do run } |
| 2 |
// GROUPS passed references |
| 3 |
// (Message bugs/refs:1) |
| 4 |
// From: [email protected] |
| 5 |
// Date: Fri, 25 Feb 94 23:55:50 -0800 |
| 6 |
// Subject: g++-2.5.8 produces incorrect code for references |
| 7 |
// Message-ID: <[email protected]> |
| 8 |
|
| 9 |
#include <stdio.h> |
| 10 |
|
| 11 |
class C { |
| 12 |
private: |
| 13 |
const char** list; |
| 14 |
public: |
| 15 |
C(const char** ); |
| 16 |
void count (int&); |
| 17 |
}; |
| 18 |
|
| 19 |
C::C (const char** l) { |
| 20 |
list = l; |
| 21 |
} |
| 22 |
|
| 23 |
void C::count (int& total) { |
| 24 |
if (*list == NULL) |
| 25 |
return; |
| 26 |
else { |
| 27 |
list++; |
| 28 |
count (++total); // THIS IS WHERE THE TROUBLE STARTS |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
const char * foo[] = { |
| 33 |
"one", "two", "three", NULL}; |
| 34 |
|
| 35 |
int main() { |
| 36 |
C c(foo); |
| 37 |
int i = 0; |
| 38 |
c.count(i); |
| 39 |
if (i == 3) |
| 40 |
printf ("PASS\n"); |
| 41 |
else |
| 42 |
{ printf ("FAIL\n"); return 1; } |
| 43 |
} |