This is the mail archive of the gcc@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: C++ and static data members...


Joe Buck writ:

>No, the purpose of a standard is to standardize existing practice, not
>to introduce new stuff that's never been seen before unless it fills
>a vital need.

This is often stated exactly in the manner above, as an absolute truth. It is
not, however, true at all in the case of C++. The issue of whether
standardization should go beyond codifying existing practice has (as you might
imagine) come up often in the C++ committee. Many people believe it should be
the aim of the committee to simply codify existing practice, but inevitably
someone will cite the committee charter which makes no attempt to limit the
effort's scope in this way. All the same, nobody on the committee (to my
knowledge) thinks it is appropriate to wantonly violate or ignore existing
practice.

>You seem to want g++ to ignore all existing practice
>and include any .o file that has a static object with a constructor.
>This would be a disaster; executable sizes would bloat, and programs
>that depend on the existing behavior would break.

If I understand the proposal I think you can find a good argument against it in
std::cout. This object is potentially initialized in every translation unit that
includes <iostream> through the use of a proxy which is actually constructed in
each unit.

3.6.2/3 allows a compiler to defer initialization of a static object until its
first use, which in the case of code that never uses cout... is never. With many
linker implementations, if the initialization gets linked in, so does everything
else in the translation unit.

It is legitimate to have a compiler option which turns this deferring behavior
off. The Metrowerks compiler, for example, includes such a switch. Still, you
should expect larger executables if you exercise that option.

-Dave



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