[Bug libstdc++/91357] _GLIBCXX_ASSERTIONS rejects possibly-valid code

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 5 16:07:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91357

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's UB, no question. The table of "Optional sequence container operations"
says a[n] is equivalent to *(a.begin() + n) so when n==a.size() you dereference
the past-the-end iterator, which is UB.


More information about the Gcc-bugs mailing list