This is the mail archive of the 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]
Other format: [Raw text]

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


------- Additional Comments From  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.

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