https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111948
--- Comment #5 from 康桓瑋 <hewillk at gmail dot com> --- It shouldn't be. Is that a compiler bug? Clang compiles the same libstdc++ code without problems.(In reply to Jonathan Wakely from comment #2) > (In reply to 康桓瑋 from comment #1) > > _M_size._M_size in the function body is already const. > > It shouldn't be. Is that a compiler bug? > > Clang compiles the same libstdc++ code without problems. Sorry, I didn't delve into whether this was a bug in libstdc++ or the compiler. At the moment it seems this is a compiler problem. https://godbolt.org/z/ronn4exhG