https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70723
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2016-04-19 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The initializer of erasedTypeVTable is not statically available but involves runtime computation: ;; Function void __static_initialization_and_destruction_0(int, int) (null) ;; enabled by -tree-original if (__initialize_p == 1) { if (__priority == 65535) { <<cleanup_point <<< Unknown tree: expr_stmt erasedTypeVTable.dtor = {anonymous}::<lambda(void*)>::operator void (*)(void*) (&TARGET_EXPR <D.5974, {}>) >>>>>; <<< Unknown tree: expr_stmt <<< Unknown tree: void_cst >>> >>>; } } ;; Function (static initializers for t.C) (null) ;; enabled by -tree-original <<cleanup_point <<< Unknown tree: expr_stmt __static_initialization_and_destruction_0 (1, 65535) >>>>>; thats probably because the lambda is not evaluated in a constexpr context. If I make erasedTypeVTable a constexpr I get t.C: In instantiation of ‘constexpr const {anonymous}::ErasedTypeVTable {anonymous}::erasedTypeVTable<{anonymous}::myType>’: t.C:36:7: required from here t.C:20:41: error: call to non-constexpr function ‘{anonymous}::<lambda(void*)>::operator void (*)(void*)() const’ static constexpr ErasedTypeVTable erasedTypeVTable = { ^~~~~~~~~~~~~~~~ not sure how I would make the lambda a constexpr. There is no pass in GCC that would try to turn the runtime initialization into static init again (optimizing the runtime initializers and parsing them back to static initializers).