------- Comment #22 from jyasskin at gmail dot com 2008-06-11 18:05 ------- This is related to generalized constant expressions (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf) in C++0x. Those will be marked by the explicit 'constexpr' keyword and will require the initialization to be done at static rather than dynamic initialization time, while this bug is about the optional optimization of moving some extra objects from dynamic to static time.
If I understand it correctly, in C++0x, the following code will require f to be placed in either the .rodata or .data sections, rather than .bss as it's placed now. struct Foo { constexpr Foo(int a) { t = a; } int t; } constexpr Foo f(1); I'd also like to point out that with the extra optimization described here, the following code could also place f in the .data section: struct Foo { constexpr Foo(int a) { t = a; } int t; } Foo f(1); // Note that f is non-const. This would be useful for getting atomic variables initialized before anything else starts up, but it may well belong in a separate feature request. -- jyasskin at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jyasskin at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4131