public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* VLAs as C++ fields - bug or feature?
@ 2000-03-25 10:53 Martin v. Loewis
  0 siblings, 0 replies; only message in thread
From: Martin v. Loewis @ 2000-03-25 10:53 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-03-25 10:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-25 10:53 VLAs as C++ fields - bug or feature? Martin v. Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).