2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / refs1.C
blob066c607045a86cbad7a9083666a262745c7b1dd3
1 // { dg-do run  }
2 // GROUPS passed references
3 // (Message bugs/refs:1)
4 // From: tal@vlsi.cs.caltech.edu
5 // Date:     Fri, 25 Feb 94 23:55:50 -0800
6 // Subject:  g++-2.5.8 produces incorrect code for references
7 // Message-ID: <9402260755.AA27693@vlsi.cs.caltech.edu>
9 #include <stdio.h>
11 class C {
12 private:
13    char** list;
14 public:
15    C(char** );
16    void count (int&);
19 C::C (char** l) {
20    list = l;
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    }
32 char * foo[] = {
33    "one", "two", "three", NULL};
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; }