http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56991
Bug #: 56991 Summary: constexpr std::initializer_list crashes on too complex initialization Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: morwen...@hotmail.fr I found some strange behaviour that, after a discussion on StackOverflow, seems to be a bug (discussion here: http://stackoverflow.com/questions/16057690/confusion-about-constant-expressions/16068953?noredirect=1#16068953). It seems that GCC implements N3471 which means that every function of an std::initializer_list are constexpr. When trying to pass simple constexpr things in the initializer_list, it works fine: #include <array> #include <initializer_list> int main() { constexpr std::array<int, 3> a = {{ 1, 2, 3 }}; constexpr int a0 = a[0]; constexpr int a1 = a[1]; constexpr int a2 = a[2]; constexpr std::initializer_list<int> b = { a0, a1, a2 }; return 0; } However, without the intermediate variables a0, a1 and a2, the example above crashes: #include <array> #include <initializer_list> int main() { constexpr std::array<int, 3> a = {{ 1, 2, 3 }}; constexpr std::initializer_list<int> b = { a[0], a[1], a[2] }; return 0; } The error is the following one: error: 'const std::initializer_list<int>{((const int*)(&<anonymous>)), 3u}' is not a constant expression This last example works fine if I remove the constexpr qualifier at the beginning of the line or if I replace the initializer_list by a std::array. It seems that the bug is only triggered when using std::initializer_list with constexpr.