This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: V3 PATCH: Static data members


Alexandre Oliva <aoliva@redhat.com> writes:

| On Nov 15, 2000, Gabriel Dos Reis <gdr@codesourcery.com> wrote:
| 
| > Mark Mitchell <mark@codesourcery.com> writes:
| > | G++ doesn't handle static data members well (they are not implicitly
| > | instantiated) on AIX, and it may not do so in the near future.  It
| > | handles *const* static data members better, because it often doesn't
| > | actually allocate storage for the constants.
| 
| > Is that a conforming behaviour? static data members have external
| > linkage and I would expect the compiler to allocate storage for such
| > beasts. 
| 
| IIRC, it *does* allocate storage when the data member is defined
| (except in case of AIX and other non-ELF platforms), but it turns out
| that references to static const data-members are often folded to the
| constant value, so we end up not needing the out-of-line, so to speak,
| definition of the static const data member.

Well, I understand your optimization concern but the case you are
describing above is a very very special case.  A static const data
member is declared in a class definition and defined somewhere in some 
translation unit part of the whole program. Unless the static data
member is initialized in the class definition (which isn't possible
for floating point types for example), the compiler doesn't know the
actual value.

I'm worrying about over-aggresive optimizations.

-- Gaby

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