From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Martin v. Loewis" To: gcc@gcc.gnu.org Subject: VLAs as C++ fields - bug or feature? Date: Sat, 25 Mar 2000 10:53:00 -0000 Message-id: <200003251850.TAA25452@loewis.home.cs.tu-berlin.de> X-SW-Source: 2000-03/msg00673.html Currently, we have a number of pending bug reports about crashes in find_function_data, which all seem to originate from code like this: struct X{ static int l; char x[l]; int y; void foo() { y=4; } }; int main() { X *x = new X; x->foo(); } Clearly, the author of this code intended to make X::l a constant. cc1plus crashes when trying to find out the offset of y in an X object; it somehow thinks we have a nested function here... Interesting enough, if foo is only declared, not defined, g++ will generate code that looks meaningful on first inspection, i.e. it will try to compute the size of X at runtime. Please let me know that this is not an extension and that the correct behaviour would be to outright reject this code. Note that it gives a VLA warning with -pedantic. Maybe I'm a pedant then, too :-) Regards, Martin