From e4cce0cea0ef842e4969469c3856529acd98db1f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 9 May 2016 11:09:37 +0100 Subject: [PATCH] libstdc++/71004 fix recursive_directory_iterator default constructor PR libstdc++/71004 * include/experimental/bits/fs_dir.h (recursive_directory_iterator): Initialize scalar member variables in default constructor. * testsuite/experimental/filesystem/iterators/ recursive_directory_iterator.cc: Teste default construction. From-SVN: r236023 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/experimental/bits/fs_dir.h | 4 ++-- .../iterators/recursive_directory_iterator.cc | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ab6df14d103..cda02f4d2e3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2016-05-09 Jonathan Wakely + + PR libstdc++/71004 + * include/experimental/bits/fs_dir.h (recursive_directory_iterator): + Initialize scalar member variables in default constructor. + * testsuite/experimental/filesystem/iterators/ + recursive_directory_iterator.cc: Teste default construction. + 2016-05-05 Rainer Orth * testsuite/lib/libstdc++.exp (libstdc++_init): Enable on *-*-solaris*. diff --git a/libstdc++-v3/include/experimental/bits/fs_dir.h b/libstdc++-v3/include/experimental/bits/fs_dir.h index 4e28c8e9240..f128ccecf7a 100644 --- a/libstdc++-v3/include/experimental/bits/fs_dir.h +++ b/libstdc++-v3/include/experimental/bits/fs_dir.h @@ -301,8 +301,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 struct _Dir_stack; std::shared_ptr<_Dir_stack> _M_dirs; - directory_options _M_options; - bool _M_pending; + directory_options _M_options = {}; + bool _M_pending = false; }; inline recursive_directory_iterator diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc index 5d2e45b2e64..a2636029f42 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc @@ -97,6 +97,16 @@ test01() remove_all(p, ec); } +void +test02() +{ + // libstdc++71004 + const fs::recursive_directory_iterator it; + assert( it.options() == fs::directory_options{} ); + assert( it.depth() == 0 ); + assert(it.recursion_pending() == false); +} + int main() { -- 2.30.2