https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103022
Bug ID: 103022 Summary: std::begin on empty std::valarray causes _GLIBCXX_DEBUG assertion Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- At least with GCC 11.2.1: > $ cat test.cc > #include <valarray> > int main() { > std::valarray<double> v; > std::begin(v); > } > $ g++ -D_GLIBCXX_DEBUG test.cc > $ ./a.out > /usr/include/c++/11/valarray:594: _Tp& > std::valarray<_Tp>::operator[](std::size_t) [with _Tp = double; std::size_t = > long unsigned int]: Assertion '__i < this->size()' failed. > Aborted because the std::begin overload is implemented via return std::__addressof(__va[0]); ever since <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=f67a9881a86bcdeb67fa52c0a8eb45ce9d4134d4> "[multiple changes]" and the std::valarray subscript operator calls __glibcxx_requires_subscript(__i); ever since <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=285b36d6a58c08792e78f9fedb3f84bdba3a4eee> "[multiple changes]". (See <https://git.libreoffice.org/core/+/82047d042e9d5d24b334eba63fd7e4c5bbbb022e%5E%21> "crashtesting: assert on conversion of fdo67521-1.odg to pdf" for an issue this caused in LibreOffice.)