On Mon, 11 Oct 2021 at 07:54, Anubhav Guleria via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
Thanks for clarifying.

Any specific reason why container's pop_back method can't check for
current size and if it is 0 then make the pop operation a no-op?

It would be a very poor design indeed to identify a bug at run-time and then to hide it from the user.

However, there's no reason why container's pop_back method can't check for this bug and trap the error. In your example, simply define `_GLIBCXX_ASSERTIONS` and you will get that behaviour (https://godbolt.org/z/WT3Y8qddz). There are more bug-checking options available. I've listed some of them here.

HTH,
John