This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
VLAs as C++ fields - bug or feature?
- To: gcc at gcc dot gnu dot org
- Subject: VLAs as C++ fields - bug or feature?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 25 Mar 2000 19:50:51 +0100
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