Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!princeton!allegra!alice!bs From: bs@alice.UUCP Newsgroups: comp.lang.c++ Subject: Re: Variable constants Message-ID: <6726@alice.uUCp> Date: Sat, 14-Mar-87 20:49:59 EST Article-I.D.: alice.6726 Posted: Sat Mar 14 20:49:59 1987 Date-Received: Sun, 15-Mar-87 08:06:26 EST References: <2032@cit-vax.Caltech.Edu> Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 31 Summary: a fix Jon Leech spotted this one: const int n = 20; double m[n][n]; extern void foo(...); f() { foo(m, &n); double x[n]; // by now cfront has forgotten that n==20 extern void fo(double m[n][n], const int *pc...); } and comments "Perhaps Bjarne would care to comment? ``Fixed in 1.2''" Unfortunately not, but here is a horrible hack that will allow cfront to remember the value of integer constants after you have taken their address. In expr2.c in expr::eval: case NAME: { Pname n = (Pname)this; if (n->n_evaluated && n->n_scope!=ARG) return n->n_val; // the following test is the fix: if (n->n_initializer && n->n_initializer && n->n_initializer->base==IVAL && n->n_initializer->i1==n->n_val) return n->n_val; if (binary_val && strcmp(string,"_result")==0) return 8888; Neval = "cannot evaluate constant"; return 1; }