This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the EGCS project.
[Bug]: non-static arrays stored in object file
- To: gcc-bugs@gcc.gnu.org
- Subject: [Bug]: non-static arrays stored in object file
- From: Steve McAndrewSmith <steve@finagle.org>
- Date: Thu, 29 Jul 1999 09:06:18 -0700
Here is (what I believe to be) a rather simple bug. It goes something
like this...
Take (the latest?) egcs (under cygwin 20.1b):
$ gcc --version
egcs-2.91.57
... and the following one-line C file.
char Foo[10000000];
compile it.
$ gcc -c foo.c
Check the object file size:
-rw-r--r-- 1 500 everyone 375 Jul 29 09:00 foo.o
All good. HOWEVER, try compiling it as C++:
$ mv foo.c foo.cc
$ gcc -c foo.cc
... and check the object file size:
-rw-r--r-- 1 500 everyone 10000383 Jul 29 09:00 foo.o
Yikes! It appears to be storing the entire *uninitialized* array in the
object file (this gets even more exciting if the array is a structure,
and padding makes the array even larger).
Workaround: declaring the array as 'static' prevents this. For my
project, this is an acceptable solution -- the array is large, so it
must not be auto, but it is only used by one function, so it need not be
extern-able.
Anything else I should try? Thanks ...
-Steve