From: CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::HELP-GCC-REQUEST" 26-FEB-1992 18:38:13.80 To: ARISIA::EVERHART CC: Subj: Re: Are these bugs in GCC2.0? From: help-gcc-request@prep.ai.mit.edu@SMTP@CRDGW2 To: Everhart@Arisia@MRGATE Received: by crdgw1.ge.com (5.57/GE 1.123) id AA10665; Wed, 26 Feb 92 18:00:34 EST Received: by life.ai.mit.edu (4.1/AI-4.10) id AA20377; Tue, 25 Feb 92 01:59:51 EST Return-Path: Received: from news.cis.ohio-state.edu by life.ai.mit.edu (4.1/AI-4.10) id AA20249; Tue, 25 Feb 92 01:56:28 EST Received: by news.cis.ohio-state.edu (5.61-kk/5.911008) id AA00566; Tue, 25 Feb 92 01:56:05 -0500 Received: from USENET by news.cis.ohio-state.edu with netnews for help-gcc@prep.ai.mit.edu (help-gcc@prep.ai.mit.edu); contact usenet@news.cis.ohio-state.edu if you have questions. To: help-gcc@prep.ai.mit.edu Date: 25 Feb 92 06:41:00 GMT Message-Id: <1992Feb25.064100.507@m.cs.uiuc.edu> Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL From: coolidge@cs.uiuc.edu (John Coolidge) Sender: help-gcc-request@prep.ai.mit.edu References: <1992Feb25.042832.28928@walter.bellcore.com>u Reply-To: coolidge@cs.uiuc.edu Subject: Re: Are these bugs in GCC2.0? 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.