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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #1)
> I view the warning as helpful here (and so not a false positive even)
> because the test function assumes the loop inserts at least three elements
> into the container.  If it doesn't, one of the pop() calls will crash.

Code is allowed to assume things that is known a priori. The compiler should
not assume every possible erroneous path is taken. If it's going to assume that
they're taken, it really needs better diagnostic messages to say *why* it
thinks there is a problem. Just stating that an error happens unconditionally
is misleading and confusing to users.

Reply via email to