Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!uwm.edu!uakari.primate.wisc.edu!ginosko!usc!orion.oac.uci.edu!uci-ics!usenet From: schmidt@glacier.ics.uci.edu (Doug Schmidt) Newsgroups: gnu.g++.bug Subject: static initialization Message-ID: <1989Oct21.181007.10849@paris.ics.uci.edu> Date: 22 Oct 89 01:10:07 GMT Reply-To: schmidt@glacier.ics.uci.edu (Doug Schmidt) Distribution: gnu Organization: University of California, Irvine - Dept of ICS Lines: 35 If you want some fun, try guessing what the `correct' output should be for the following C++ code accepted without warning from G++. Then compile and execute it with G++ and check your work. ---------------------------------------- #include int *frob(int k) { static int N[2] = {k, k}; return N; } main () { int i; for (i = 5; i < 10; i++) printf ("i = %d\n", frob(i)[1]); } ---------------------------------------- cfront 2.0 complains: "yow.c", line 13: sorry, not implemented: local name k in initializer for static I think I like the G++ solution, although it is not clear exactly what the `official' output should be. Doug -- Master Swordsman speak of humility; | schmidt@ics.uci.edu (ARPA) Philosophers speak of truth; | office: (714) 856-4034 Saints and wisemen speak of the Tao of no doubt; The moon, sun, and sea speaks for itself. -- Hiroshi Hamada