This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18894] New: Array declaration in functions accepting variable size
- From: "clippyhater at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Dec 2004 21:34:50 -0000
- Subject: [Bug c++/18894] New: Array declaration in functions accepting variable size
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In a c++ source file, the following code compiles cleanly:
#include <iostream>
using namespace std;
void foo(int n) {
int myArray[n];
for (int i=0 ; i<n ; i++)
myArray[i] = i;
}
int main()
{
int z = 1000;
foo(z);
cout << "returning from foo..." << endl;
return 0;
}
I believe this is incorrect behavior for the C++ standard--compilation should
fail on "int myArray[n];" in the function "foo(int n)".
--
Summary: Array declaration in functions accepting variable size
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: clippyhater at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18894