https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100366
--- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> --- Just to clarify: when I said the warning is justified I meant that there is nothing in the IL to keep the warning from triggering. I.e., it works as designed. The problem may be solved by optimizing the code better, which might be possible by enhancing the optimizers or by changing or annotating the libstdc++ code to enable existing optimizations. In the latter case it will of course only help libstdc++ and not other code like it. A third possibility is to make the warning itself smarter than the optimizer and figure out the code is unreachable without its help.