[gcc r16-7824] libstdc++: Add test for -Wnull-deference in istream_iterator [PR105580]
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Sat Feb 28 07:48:04 GMT 2026
https://gcc.gnu.org/g:8758503918a91dacff4dbc7126eced21787fbfc9
commit r16-7824-g8758503918a91dacff4dbc7126eced21787fbfc9
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Fri Feb 27 19:55:19 2026 +0100
libstdc++: Add test for -Wnull-deference in istream_iterator [PR105580]
PR libstdc++/105580
libstdc++-v3/ChangeLog:
* testsuite/24_iterators/istreambuf_iterator/105580.cc: New test.
Diff:
---
.../testsuite/24_iterators/istreambuf_iterator/105580.cc | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc
new file mode 100644
index 000000000000..85f888b86e72
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc
@@ -0,0 +1,16 @@
+// { dg-compile }
+// { dg-require-normal-mode "" }
+// { dg-additional-options "-Wnull-dereference" }
+
+#include <string>
+#include <sstream>
+
+int main()
+{
+ std::istringstream in("Hello, world");
+ std::istreambuf_iterator<char> it(in), end;
+ std::string ss(it, end);
+ return 0;
+}
+// { dg-warning ".*null pointer dereference" "" { target *-*-* } 0 }
+
More information about the Libstdc++-cvs
mailing list