diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf index d6036bd5ddc..f013aa06c28 100644 --- a/libstdc++-v3/include/std/streambuf +++ b/libstdc++-v3/include/std/streambuf @@ -490,6 +490,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char_type* eback() const { return _M_in_beg; } +// Required to silence false-positive warnings originating from istream_iterator::operator++, +// see PR105580. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnull-dereference" char_type* gptr() const { return _M_in_cur; } @@ -505,6 +509,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ void gbump(int __n) { _M_in_cur += __n; } +#pragma GCC diagnostic pop /** * @brief Setting the three read area pointers. diff --git a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc index 85f888b86e7..87edf999ffc 100644 --- a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc +++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc @@ -1,5 +1,4 @@ // { dg-compile } -// { dg-require-normal-mode "" } // { dg-additional-options "-Wnull-dereference" } #include @@ -12,5 +11,4 @@ int main() std::string ss(it, end); return 0; } -// { dg-warning ".*null pointer dereference" "" { target *-*-* } 0 }