https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105580
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |libstdc++
Summary|[12/13 Regression] False |[12/13 Regression] warning
|warning "potential null |"potential null pointer
|pointer dereference" raised |dereference" raised when
|when using |using istreambuf_iterator
|istreambuf_iterator and any |and any "-O" flag
|"-O" flag |
CC| |jason at gcc dot gnu.org
--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
The theory of the warning seems to be that if istreambuf_iterator::_M_get,
called from operator* for *__beg in _M_construct, hits EOF, it clears _M_sbuf,
and then ++__beg will try to refer to members of the now-null __beg._M_sbuf.
At first glance, this seems like a plausible theory. Why does _M_get clear
_M_sbuf?
int_type
_M_get() const
{
int_type __ret = _M_c;
if (_M_sbuf && _S_is_eof(__ret) && _S_is_eof(__ret = _M_sbuf->sgetc()))
_M_sbuf = 0;
return __ret;
}