public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18713] New: Large program size due to uninitialised global data (SCO)
@ 2004-11-29  8:15 bygoh at genting dot com dot my
  2004-11-29 13:40 ` [Bug target/18713] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bygoh at genting dot com dot my @ 2004-11-29  8:15 UTC (permalink / raw)
  To: gcc-bugs

Configured with: ../sco/gcc-3.2.3/configure --prefix=/usr/local/gcc-3.2.3 --
enable-languages=c++ --with-gnu-as
Thread model: single
gcc version 3.2.3

System: SCO Unix 5.0.5

Compilation of source programs with declared but unitialised global data on the 
SCO system seems to cause the program to grow in proportion with the size of 
the data. Uninitialised data should be stored under BSS or the common section 
of a program. This seems to be the case for Linux but not on SCO.

-----
Test program: foo.cpp

struct My_t {
        char            myData[2048];
};
My_t myArr[10240];

int main ()
{
        return 0;
}

-----
Compilation: gcc -O -fconserve-space foo.cpp -lstdc++
Size listing (ls -l a.out) on SCO: 20977120
Size listing (ls -l a.out) on RedHat: 11341

However, converting the same program to a C standard and compiling with gcc on 
SCO produces the expected object code size as follows:

-----
Test program: foo.c

struct My_t {
        char            myData[2048];
};
struct My_t myArr[10240];

int
main ()
{
        return 0;
}

-----
Compilation: gcc foo.c
Size listing (ls -l a.out) on SCO: 5604

-- 
           Summary: Large program size due to uninitialised global data
                    (SCO)
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bygoh at genting dot com dot my
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18713] Large program size due to uninitialised global data (SCO)
  2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
@ 2004-11-29 13:40 ` pinskia at gcc dot gnu dot org
  2004-12-08  4:12 ` bygoh at genting dot com dot my
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-29 13:40 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target
           Keywords|                            |missed-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18713] Large program size due to uninitialised global data (SCO)
  2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
  2004-11-29 13:40 ` [Bug target/18713] " pinskia at gcc dot gnu dot org
@ 2004-12-08  4:12 ` bygoh at genting dot com dot my
  2004-12-08  8:56 ` [Bug target/18713] Large program size due to uninitialised global data steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bygoh at genting dot com dot my @ 2004-12-08  4:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bygoh at genting dot com dot my  2004-12-08 04:11 -------
Follow up on the earlier report, the size problem goes away when the global 
variables are declared as static:

struct My_t {
        char            myData[2048];
};
static My_t myArr[10240];

int main ()
{
        return 0;
}

Using nm on the object files that were generated:
without static keyword:
Symbols from foo.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[1]     |         0|       0|FILE |LOCL |0    |ABS    |foo.cpp
[2]     |         0|       0|SECT |LOCL |0    |2      |
[3]     |         0|       0|SECT |LOCL |0    |4      |
[4]     |         0|       0|SECT |LOCL |0    |5      |
[5]     |         0|       0|SECT |LOCL |0    |1      |
[6]     |         0|       0|SECT |LOCL |0    |6      |
[7]     |         0|20971520|OBJT |GLOB |0    |4      |myArr
[8]     |         0|      30|FUNC |GLOB |0    |2      |main

with static keyword:
Symbols from foo.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[1]     |         0|       0|FILE |LOCL |0    |ABS    |foo.cpp
[2]     |         0|       0|SECT |LOCL |0    |2      |
[3]     |         0|       0|SECT |LOCL |0    |4      |
[4]     |         0|       0|SECT |LOCL |0    |5      |
[5]     |         0|20971520|OBJT |LOCL |0    |5      |myArr
[6]     |         0|       0|SECT |LOCL |0    |1      |
[7]     |         0|       0|SECT |LOCL |0    |6      |
[8]     |         0|      30|FUNC |GLOB |0    |2      |main

The array was bound locally. Still doesn't solve the problem but its a work 
around for programs with a main line entry point.

NOTE: static is deprecated in a global context. Not that its going to go away 
or anything...

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18713] Large program size due to uninitialised global data
  2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
  2004-11-29 13:40 ` [Bug target/18713] " pinskia at gcc dot gnu dot org
  2004-12-08  4:12 ` bygoh at genting dot com dot my
@ 2004-12-08  8:56 ` steven at gcc dot gnu dot org
  2004-12-14 10:03 ` bygoh at genting dot com dot my
  2005-04-04 14:43 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2004-12-08  8:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2004-12-08 08:56 -------
Bugs for gcc 3.2.3 are not going to be fixed.  Are you seeing this 
problem with more recent versions of GCC as well? 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
            Summary|Large program size due to   |Large program size due to
                   |uninitialised global data   |uninitialised global data
                   |(SCO)                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18713] Large program size due to uninitialised global data
  2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
                   ` (2 preceding siblings ...)
  2004-12-08  8:56 ` [Bug target/18713] Large program size due to uninitialised global data steven at gcc dot gnu dot org
@ 2004-12-14 10:03 ` bygoh at genting dot com dot my
  2005-04-04 14:43 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bygoh at genting dot com dot my @ 2004-12-14 10:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bygoh at genting dot com dot my  2004-12-14 10:03 -------
Have been trying to upgrade to a newer version of gcc (3.3.3 and above). But I 
am getting an error during compilation:

checking whether the C compiler ( /usr/byg/src/bld-gcc/gcc/xgcc -B/usr/byg/src/b
ld-gcc/gcc/ -B/usr/local/gcc-3.3.4/i386-pc-sco3.2v5.0.5/bin/ -B/usr/local/gcc-3.
3.4/i386-pc-sco3.2v5.0.5/lib/ -isystem /usr/local/gcc-3.3.4/i386-pc-sco3.2v5.0.5
/include -O2 -O2 ) works... no
configure: error: installation or configuration problem: C compiler cannot creat
e executables.
gmake: *** [configure-target-libiberty] Error 1

Any idea how to get past this?

Configured and built with:
$ configure --prefix=/usr/local/gcc-3.3.4 --enable-languages="c++"
$ gmake CFLAGS="-O2" LANGUAGES="c c++"

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18713] Large program size due to uninitialised global data
  2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
                   ` (3 preceding siblings ...)
  2004-12-14 10:03 ` bygoh at genting dot com dot my
@ 2005-04-04 14:43 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-04 14:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-04 14:43 -------
No useful feedback in 3 months.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-04 14:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-29  8:15 [Bug c++/18713] New: Large program size due to uninitialised global data (SCO) bygoh at genting dot com dot my
2004-11-29 13:40 ` [Bug target/18713] " pinskia at gcc dot gnu dot org
2004-12-08  4:12 ` bygoh at genting dot com dot my
2004-12-08  8:56 ` [Bug target/18713] Large program size due to uninitialised global data steven at gcc dot gnu dot org
2004-12-14 10:03 ` bygoh at genting dot com dot my
2005-04-04 14:43 ` pinskia at gcc dot gnu dot org

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).