https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84587
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #2) > The testcase has undefined behavior; the initializer_list array only lives > until the end of the initialization of 'a'. > > 11.6.4p6: The array has the same lifetime as any other temporary object > (15.2), except that initializing an initializer_list object from the array > extends the lifetime of the array exactly like binding a reference to a > temporary. > > 15.2p6.9: A temporary object bound to a reference parameter in a function > call (8.5.1.2) persists until the completion of the full-expression > containing the call. > > The code can be fixed by explicitly extending the initializer_list lifetime, > e.g. > > std::initializer_list<const char> il = {'a', 'b', 'c'}; > ArrayView<const char> a (il); Thank you Jason for nice clarification ;)