On Sat, Feb 28, 2026 at 2:32 AM Jonathan Wakely <[email protected]> wrote:
> > > On Fri, 27 Feb 2026, 22:23 Tomasz Kaminski, <[email protected]> wrote: > >> >> On Fri, Feb 27, 2026 at 11:05 PM Tomasz Kamiński <[email protected]> >> wrote: >> >>> libstdc++ PR/105580 >>> >>> libstdc++-v3/ChangeLog: >>> >>> * testsuite/24_iterators/istreambuf_iterator/105580.cc: New test. >>> --- >>> Pushing a test checking for warning as separate commit, as it make it >>> easier for me to reliably detect if fix works. >>> >>> Tested the new file with all standard modes. OK for trunk? >>> >> I turns out that the warning is not emitted for _GLIBCXX_DEBUG, and >> making it >> conditionally unsupported if !debug, is not worth extra complexity. >> Especially when >> warnings will be not-emitted after fix-up commit. >> > > I think you can just add: > > { dg-require-normal-mode "" } > Thanks, I will try to remember that, I wasn't able to find it late last night. > > But I agree it's not needed, most people won't get it with debug mode > enabled and it will stop warning later anyway. > > I didn't mean that a test to detect the warning needs to be added > separately. It would be fine to just push the test in the same commit with > the fix, as long as you've verified locally that it failed before the fix. > Yes, that was clear to me. The separate test commit was purely to help me with development, and have more to do with me trusting myself not to lose track of the test file when testing multiple options. I can use one command line to test many standard versions and modes. Furthermore, in my career, I have often thought I found a nice solution to the problem (especially with false-positive warning), only to realize I either accidentally dropped the test replaced one diagnostic with a slightly different one. dg-gnu will catch that for me without my needing to look at full output of the compilation. And a separate commit means I get just do a git diff for a sanity check to see if test is passing, because I removed the check for warning, or maybe is still there. If test commit is in trunk, I can simply diff against trunk. Also as bonus I will not loose test commit while rebasing. > > But it's ok this way too. OK for trunk > Added dg-require-normal-mode, updated {} to () and pushing to trunk. > > >>> .../24_iterators/istreambuf_iterator/105580.cc | 15 +++++++++++++++ >>> 1 file changed, 15 insertions(+) >>> create mode 100644 >>> libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc >>> >>> 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 00000000000..7c70b8237c3 >>> --- /dev/null >>> +++ b/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/105580.cc >>> @@ -0,0 +1,15 @@ >>> +// { dg-compile } >>> +// { dg-additional-options "-Wnull-dereference" } >>> + >>> +#include <string> >>> +#include <sstream> >>> + >>> +int main() >>> +{ >>> + std::istringstream in{"Hello, world"}; >>> >> Changed {} to parenthesise here and 2 lines below for C++98. > + std::istreambuf_iterator<char> it(in), end; >>> + std::string ss{it, end}; >>> + return 0; >>> +} >>> +// { dg-warning ".*null pointer dereference" "" { target *-*-* } 0 } >>> + >>> -- >>> 2.53.0 >>> >>>
