https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61290
Bug ID: 61290 Summary: init templated member variable with constructor fails Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tower120 at gmail dot com This one related to this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51666 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52595 Consider the following code: struct S{ //typedef S ThisT; template<class IdsT, class DataT> struct CallbackPack{ CallbackPack(IdsT &selfIds): selfIds(selfIds){} const IdsT &selfIds; }; const CallbackPack<S, S> callbackPack123 = CallbackPack<S, S>((*this)); }; int main() { return 0; } http://coliru.stacked-crooked.com/a/ea9ed4482306ce17 Which produce the following errors: main.cpp:16:65: error: expected ';' at end of member declaration const CallbackPack<S, S> callbackPack123 = CallbackPack<S, S>((*this)); ^ main.cpp:16:66: error: expected unqualified-id before '>' token const CallbackPack<S, S> callbackPack123 = CallbackPack<S, S>((*this)); ^ main.cpp:16:65: warning: non-static const member 'const S::CallbackPack<S, S> S::S' in class without a constructor [-Wuninitialized] const CallbackPack<S, S> callbackPack123 = CallbackPack<S, S>((*this)); ^ main.cpp:16:62: error: wrong number of template arguments (1, should be 2) const CallbackPack<S, S> callbackPack123 = CallbackPack<S, S>((*this)); ^ main.cpp:9:12: error: provided for 'template<class IdsT, class DataT> struct S::CallbackPack' struct CallbackPack{ ------------------------------------------------------------------------ The workarounds for this: const CallbackPack<S, S> callbackPack123 = (CallbackPack<S, S>((*this))); http://coliru.stacked-crooked.com/a/f8658477b7379e8e and const CallbackPack<S, S> callbackPack123{*this}; http://coliru.stacked-crooked.com/a/3e0c71de722801bb