Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!POLYA.STANFORD.EDU!robert From: robert@POLYA.STANFORD.EDU (Robert Kennedy) Newsgroups: gnu.g++.bug Subject: Bug with variable-length arrays in argument list Message-ID: Date: 4 Aug 89 21:28:23 GMT Sender: kathy@tut.cis.ohio-state.edu Reply-To: Robert Kennedy Distribution: gnu Organization: GNUs Not Usenet Lines: 46 Running version 1.35.1- on a Sun 4/110, SunOS: Variable length arrays as described on page 46 of the manual are broken. ----------------- begin c++ program --------------------- #include void gripe(int a, char c[a]) { cout << c[0]; } main() { gripe(2, "T"); } ----------------- begin g++ output --------------------- winge.cc:3: `a' undeclared, outside of functions winge.cc:5: parameter `c' has incomplete type In function void gripe (int, _0): winge.cc:6: `c' was not declared (first use this function) winge.cc:6: (Each undeclared identifier is reported only once winge.cc:6: for each function it appears in.) In function int main (): winge.cc:13: parameter type of called function is incomplete ------------------------ end g++ output --------------------- Note also that the following program should compile and work in the obvious way (but doesn't -- compiler output excluded for brevity): #include void multiwinge(int a, char c[][a]) { cout << c[1][0]; } main() { multiwinge(2, "Should print u"); }