This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static lib drops objects with side-effects


On Tue, Feb 11, 2003 at 11:41:54AM +1030, Alan Modra wrote:
> On Mon, Feb 10, 2003 at 05:03:04PM +0100, Wesley W. Terpstra wrote:
> > This is a bug.
> 
> No it isn't.  Objects are extracted from archives during linking only
> if the object contains a symbol satisfying an undefined symbol
> reference. 

I understand this. This behaviour is correct for C and was correct for C++
for some time. However, as there is now a standard which states what the
correct behaviour is, this is no longer correct.

> If this behaviour is incompatible with your C++ model then don't use
> archives.

This is not a problem with 'my C++ model'.
This is a problem with standard C++ on GNU tools and static libs.
This changes the startup behaviour of standards conforming C++ programs.

The GNU binutils causes the GNU compiler suite to be non-standards
conforming. The standard requires objects whose constructors have
side-effects to be included. The biggest problem with violating this 
section of the standard is it breaks a commonly used C++ design pattern
which many people are taught in school---and expect to work!

I already have workarounds, but that is not the issue. The issue is that
this behaviour really is broken---for C++ on GNU binutils.

I am not proposing that all objects be pulled in from an archive. However, a
simple flag like Daniel Jacobowitz proposed that marks objects with
non-trivial constructors for inclusion would be sufficient to correct this
bug.

Please explain to me how behaviour which explicitly contradicts the standard
can be anything other than a bug.

For your reference here is a link to an old (free) version of the C++
standard (section 3.6.1.2):
http://www.surakware.net/projects/qpascal/specification/language/chapter03_5.xml

---
Wes


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]