[Bug c++/11211] trivial static initializers of const objects should be done at compile time

eric-gcc@omnifarious.org gcc-bugzilla@gcc.gnu.org
Mon Jun 16 23:43:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11211



------- Additional Comments From eric-gcc@omnifarious.org  2003-06-16 23:43 -------
After reading those sections, I think the optimization could only be applied in
some limited, but possibly still useful circumstances.  The order in which
constructors are run for global variables is undefined between translation
units.  So, the optimization could only be applied when the definitions of afred
and abarney appeared before everything else in the translation unit.

The standard would have to say something about all the constructors from one
translation unit always being run either before, or after the constructors in
another translation unit, and I don't think it does.

Also, if the variables were static variables in a function, then you couldn't
apply the optimization, since the constructors for such variables aren't
supposed to be run until the funtion is called the first time.  Static,
function-scope variables shouldn't be subject to the suggested optimization.

Of course, I'm only a novice language lawyer, and don't have the exact text of
the standard sitting in front of me.



More information about the Gcc-bugs mailing list