www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/24/13:49:05

Message-ID: <3BD6FAAA.6080402@edu.stadia.fi>
From: Antti Koskipaa <antti DOT koskipaa AT edu DOT stadia DOT fi>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.5) Gecko/20011011
X-Accept-Language: en-us
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Weird behaviour of the C++ compiler.
Lines: 70
Date: Wed, 24 Oct 2001 20:30:18 +0300
NNTP-Posting-Host: 212.38.225.12
X-Trace: uutiset.nic.fi 1003944597 212.38.225.12 (Wed, 24 Oct 2001 20:29:57 EET DST)
NNTP-Posting-Date: Wed, 24 Oct 2001 20:29:57 EET DST
Organization: NIC Tietoverkot Oy - NIC Data Networks Ltd.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi. I was trying C++ with DJGPP the other day. The compiler accepts
the input file, and passes it to the assembler. The assembler
chokes on it. I'm not a pro in C++, only C so I can't really
tell whether the compiler or code has the error.

Here are some of the ~90 error messages I get:

c:\source>gcc -c hello.cpp
Z:\ccSMxCUe.s: Assembler messages:
Z:\ccSMxCUe.s:2718: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNSsD1Ev"
Z:\ccSMxCUe.s:2804: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNSsD1Ev"
Z:\ccSMxCUe.s:2805: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNSsaSERKSs"
Z:\ccSMxCUe.s:2826: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNKSt8numpunctIcE9falsenameEv"
Z:\ccSMxCUe.s:2856: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNKSt8numpunctIcE13thousands_sepEv"
Z:\ccSMxCUe.s:2880: Error: Too many new sections; can't add 
".gnu.linkonce.t._ZNKSt8numpunctIcE13decimal_pointEv"

etc. When compiling with gcc -S hello.cpp, the resulting asm
file is over 7000 lines long! Now I knew that C++ had something
to do with "bloat", but this is ridiculous...

Here's the source: (and yes, it pretty useless...)

// The hard way to say hello...

#include <iostream.h>

class HelloWorld {
private:
     char *HelloWorldStr;

public:
     void SayIt ();
     HelloWorld ();
     ~HelloWorld ();
};

HelloWorld::HelloWorld ()
{
     HelloWorldStr = new char[20];
     strcpy (HelloWorldStr, "Hello, World!");
}

HelloWorld::~HelloWorld ()
{
     delete[] HelloWorldStr;
}

void HelloWorld::SayIt ()
{
     cout << HelloWorldStr << endl;
}

int main ()
{
     HelloWorld* Hello = new HelloWorld;
     Hello->SayIt ();
     delete Hello;

     return 0;
}

--
- Antti

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019