This is the mail archive of the mailing list for the libstdc++ project.

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

Re: PR3042

>>>>> "David" == David Edelsohn <> writes:

    David> 	Mark's proposal is "define nowhere" -- to quote Mark.
    David> To be explicit:

    David>   static int i = 7;

    David> allocates storage.

    David>   static int i;

    David> does not allocate storage, only a reference to the symbol.

I'm not sure whether you mean to indicate what happens now, or what
would happen with my change.

Right now, the former does not allocate storage, while the latter
does.  Under my poposal, neither would llocate storage.

    David> 	If COMMON symbols in objects and shared libraries are
    David> merged (as they are for ELF-based systems and the other
    David> non-AIX systems and AIX using the linker -brtl option),
    David> then the above example will behave the same on AIX for both
    David> cases without Mark's change.  This will be the same
    David> behavior as on other platforms.

I'm not sure which example you're talking about.  AIX will *not*
behave the same as ELF platforms, with any change we are discussing.

    David> 	I believe that "static" must allocate storage.

Then you must be unhappy with the current state.  It does not, if you
initialize it.

    David> program.  Until AIX supports WEAK symbols, AIX requires
    David> some form of single instantiation
    David> (-fno-implicit-instantiation, -frepo, etc.)

Actually, what is required on AIX is not that you turn off implicit
instantiation -- it is that you add explicit instantiation.  Some
implicit instantiations work just fine on AIX.

On an ELF system, -fno-implicit-instantiation is mostly a way of
optimizing compile-times, or creating more compact code.  Technically,
-fno-implicit-instantiation means "I am programming in a restricted
subset of C++, not the full language."  All programs that are legal
with -fno-implicit-instantiation are legal without it as well.

    David> work on AIX and other systems without WEAK symbols.  In
    David> other words, make implicit template instantiation COMDAT
    David> support more like static class members, instead of
    David> vice-versa.

Yes, you can turn static initializations into dynamic initializations,
so that you can then use COMMON.  You will disappoint some of your
user-base, because performance will degrade.  In addition, order of
initialization issues make it very difficult (read impossible, unless
you make *all* initializations, even for non-templates, dynamic) to
get correct C++ semantics in this way.  You will also get odd
incompatibilities between G++ on AIX and on other systems where, for
example, shared libraries don't initialize themselves properly on

To my knowledge, no compiler has ever implemented this approach, for
these reasons.  I am happy to stand corrected if people know of

Mark Mitchell         
CodeSourcery, LLC     

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