🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53279

Re: Are these bugs in GCC2.0?

#53279
From: John Coolidge
Date: Tue, 25 Feb 1992 06:41
30 lines
2223 bytes
ngai@apostle.bellcore.com (John Ngai) writes:
>I used GCC 2.0 to recompile some of my existing code, and seem to find
>the following "bugs":
>(2) Initialization of global static objects with constructors doesn't seem
>    to call their corresponding constructors, eg:

> [Example deleted]

>    Among other things, I got an arithmetic exception in calling insert 
>    because of a division by zero in my internal hash function, which depends 
>    on having table_size initialized correctly. Checking with a debugger
>    reveals that the constructor never gets called. 

This might be a linker problem. GCC 2.0 relies on generating a call to
its __main from your main() function. In turn, __main runs through a
list of static constructors and calls them. If your system doesn't
support building such a table with ld (many don't), you need to build
collect2 and force gcc to run it as ld. Collect will run through the
table and build the static constructor and destructor lists.

I had identical problems until I get collect2 up and running. Now my
static constructor/destructor test case runs correctly.

--John

--------------------------------------------------------------------------
John L. Coolidge   til May: coolidge@cs.uiuc.edu   May: coolidge@apple.com
Of course I don't speak for the U of I, Apple, or anyone else except myself
Copyright 1992 John L. Coolidge. Copying allowed if (and only if) attributed.
You may redistribute this article if and only if your recipients may as well.
Technical Details
Message-ID: <1992Feb25.064100.507@m.cs.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!uwm.edu!linac!mp.cs.niu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!coolidge
References: <1992Feb25.042832.28928@walter.bellcore.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,503a0bf4dd3425e2
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-02-24 23:08:47 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!uwm.edu!linac!mp.cs.niu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!coolidge
From: coolidge@cs.uiuc.edu (John Coolidge)
Subject: Re: Are these bugs in GCC2.0?
Message-ID: <1992Feb25.064100.507@m.cs.uiuc.edu>
Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager))
Reply-To: coolidge@cs.uiuc.edu
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
References: <1992Feb25.042832.28928@walter.bellcore.com>
Date: Tue, 25 Feb 1992 06:41:00 GMT