aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2019-05-07 17:31:12 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2019-05-07 17:31:12 +0000
commiteec33732a01453baedb2598c6997bad6a39d9e1e (patch)
tree15c52c0770d845cf0053e959a8b998cda7ddec25
parent6ffaf63f736250e03afb9974fe5a32b50c69bdef (diff)
parenta91db438b583050311a6eb845d05775b14e09f1d (diff)
svn merge -r270931:270974 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branchredhat/gcc-8-branch
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/redhat/gcc-8-branch@270976 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/Makefile.in5
-rw-r--r--gcc/cp/ChangeLog31
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/cp/typeck2.c25
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-value4.C12
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-conv2.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/using-enum-3.C21
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aggr-base8.C48
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/aggr-base9.C33
-rw-r--r--gcc/testsuite/g++.dg/warn/conv5.C11
-rw-r--r--libstdc++-v3/ChangeLog136
-rw-r--r--libstdc++-v3/doc/html/manual/using_macros.html3
-rw-r--r--libstdc++-v3/doc/xml/faq.xml24
-rw-r--r--libstdc++-v3/doc/xml/manual/debug.xml79
-rw-r--r--libstdc++-v3/doc/xml/manual/evolution.xml9
-rw-r--r--libstdc++-v3/doc/xml/manual/intro.xml16
-rw-r--r--libstdc++-v3/doc/xml/manual/using.xml4
-rw-r--r--libstdc++-v3/include/bits/forward_list.tcc6
-rw-r--r--libstdc++-v3/include/bits/fs_path.h3
-rw-r--r--libstdc++-v3/include/bits/hashtable.h11
-rw-r--r--libstdc++-v3/include/bits/stl_queue.h8
-rw-r--r--libstdc++-v3/include/bits/stl_tree.h27
-rw-r--r--libstdc++-v3/include/bits/uses_allocator.h11
-rw-r--r--libstdc++-v3/include/std/optional2
-rw-r--r--libstdc++-v3/include/std/type_traits7
-rw-r--r--libstdc++-v3/include/std/variant12
-rw-r--r--libstdc++-v3/libsupc++/hash_bytes.cc2
-rw-r--r--libstdc++-v3/src/filesystem/std-dir.cc8
-rw-r--r--libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc13
-rw-r--r--libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/hash/89629.cc43
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc38
-rw-r--r--libstdc++-v3/testsuite/20_util/optional/observers/4.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc14
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/variant/compile.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc44
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc60
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/48101_neg.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc6
-rw-r--r--libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc50
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/85965.cc29
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc29
-rw-r--r--libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc76
-rw-r--r--libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc18
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_hooks.h11
58 files changed, 1011 insertions, 110 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 97a2af05ec4..d7fde23c7b1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * gcc-interface/Makefile.in (install-gcc-specs): Use foreach.
+ Honor DESTDIR.
+
2019-02-23 Eric Botcazou <ebotcazou@adacore.com>
PR ada/89349
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 04263e1cf8a..61d1e105ba7 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -2285,9 +2285,8 @@ gnatlink-re: ../stamp-tools gnatmake-re
install-gcc-specs:
# Install all the requested GCC spec files.
- for f in $(GCC_SPEC_FILES); do \
- $(INSTALL_DATA_DATE) $(srcdir)/ada/$$f $(libsubdir)/; \
- done
+ $(foreach f,$(GCC_SPEC_FILES), \
+ $(INSTALL_DATA_DATE) $(srcdir)/ada/$(f) $(DESTDIR)$(libsubdir)/;)
install-gnatlib: ../stamp-gnatlib-$(RTSDIR) install-gcc-specs
$(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fc0e6a4cc6e..ba00c9ddb34 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,34 @@
+2019-05-07 Marek Polacek <polacek@redhat.com>
+
+ Backported from mainline
+ 2019-02-27 Marek Polacek <polacek@redhat.com>
+
+ PR c++/88857 - ICE with value-initialization of argument in template.
+ * call.c (convert_like_real): Don't call build_value_init in template.
+
+ 2019-03-25 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89214 - ICE when initializing aggregates with bases.
+ * typeck2.c (digest_init_r): Warn about object slicing instead of
+ crashing.
+
+ 2019-02-27 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89511 - ICE with using-declaration and unscoped enumerator.
+ * parser.c (cp_parser_using_declaration): For an unscoped enum
+ only use its context if it's not a function declaration.
+
+ 2019-03-25 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89705 - ICE with reference binding with conversion function.
+ * call.c (reference_binding): If the result of the conversion function
+ is a prvalue of non-class type, use the cv-unqualified type.
+
+ 2019-03-29 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89876 - ICE with deprecated conversion.
+ * call.c (convert_like_real): Only give warnings with tf_warning.
+
2019-04-30 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f16f2895402..11bd5420fe7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1767,6 +1767,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
&& DECL_CONV_FN_P (t->cand->fn))
{
tree ftype = TREE_TYPE (TREE_TYPE (t->cand->fn));
+ /* A prvalue of non-class type is cv-unqualified. */
+ if (TREE_CODE (ftype) != REFERENCE_TYPE && !CLASS_TYPE_P (ftype))
+ ftype = cv_unqualified (ftype);
int sflags = (flags|LOOKUP_NO_CONVERSION)&~LOOKUP_NO_TEMP_BIND;
conversion *new_second
= reference_binding (rto, ftype, NULL_TREE, c_cast_p,
@@ -6775,7 +6778,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
/* If we're initializing from {}, it's value-initialization. */
if (BRACE_ENCLOSED_INITIALIZER_P (expr)
&& CONSTRUCTOR_NELTS (expr) == 0
- && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype))
+ && TYPE_HAS_DEFAULT_CONSTRUCTOR (totype)
+ && !processing_template_decl)
{
bool direct = CONSTRUCTOR_IS_DIRECT_INIT (expr);
if (abstract_virtuals_error_sfinae (NULL_TREE, totype, complain))
@@ -7110,7 +7114,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
case ck_qual:
/* Warn about deprecated conversion if appropriate. */
- string_conv_p (totype, expr, 1);
+ if (complain & tf_warning)
+ string_conv_p (totype, expr, 1);
break;
case ck_ptr:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index f69e80b6e03..921916a0844 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18815,7 +18815,8 @@ cp_parser_using_declaration (cp_parser* parser,
/*is_declaration=*/true);
if (!qscope)
qscope = global_namespace;
- else if (UNSCOPED_ENUM_P (qscope))
+ else if (UNSCOPED_ENUM_P (qscope)
+ && !TYPE_FUNCTION_SCOPE_P (qscope))
qscope = CP_TYPE_CONTEXT (qscope);
if (access_declaration_p && cp_parser_error_occurred (parser))
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 34284074a21..b28044c11dc 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1142,8 +1142,29 @@ digest_init_r (tree type, tree init, int nested, int flags,
{
tree elt = CONSTRUCTOR_ELT (init, 0)->value;
if (reference_related_p (type, TREE_TYPE (elt)))
- /* We should have fixed this in reshape_init. */
- gcc_unreachable ();
+ {
+ /* In C++17, aggregates can have bases, thus participate in
+ aggregate initialization. In the following case:
+
+ struct B { int c; };
+ struct D : B { };
+ D d{{D{{42}}}};
+
+ there's an extra set of braces, so the D temporary initializes
+ the first element of d, which is the B base subobject. The base
+ of type B is copy-initialized from the D temporary, causing
+ object slicing. */
+ tree field = next_initializable_field (TYPE_FIELDS (type));
+ if (field && DECL_FIELD_IS_BASE (field))
+ {
+ if (warning_at (loc, 0, "initializing a base class of type %qT "
+ "results in object slicing", TREE_TYPE (field)))
+ inform (loc, "remove %<{ }%> around initializer");
+ }
+ else
+ /* We should have fixed this in reshape_init. */
+ gcc_unreachable ();
+ }
}
if (BRACE_ENCLOSED_INITIALIZER_P (init)
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C b/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C
new file mode 100644
index 00000000000..427147ff7f2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-value4.C
@@ -0,0 +1,12 @@
+// PR c++/88857
+// { dg-do compile { target c++11 } }
+
+class S { int a; };
+void foo (const S &, int);
+
+template <int N>
+void
+bar ()
+{
+ foo ({}); // { dg-error "too few arguments to function" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C b/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
new file mode 100644
index 00000000000..9b9b154995b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
@@ -0,0 +1,18 @@
+// PR c++/89705
+// { dg-do compile { target c++11 } }
+
+struct W { operator const volatile int(); };
+const int& rci = W();
+
+struct X { operator const int(); };
+int&& rri = X();
+
+struct Y { operator volatile int(); };
+int&& rri2 = Y();
+
+struct Z { operator const volatile int(); };
+volatile int&& rri3 = Z();
+
+enum E { A };
+struct S { operator const E(); };
+E&& rre = S();
diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C
new file mode 100644
index 00000000000..edc16890cb1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C
@@ -0,0 +1,21 @@
+// PR c++/89511
+// { dg-do compile { target c++11 } }
+
+void f ()
+{
+ enum e { a };
+ using e::a; // { dg-error "not a namespace or unscoped enum" }
+}
+
+struct S {
+ enum E { A };
+ using E::A; // { dg-error "type .S. is not a base type for type .S." }
+};
+
+namespace N {
+ enum E { B };
+}
+
+struct T {
+ using N::E::B; // { dg-error "using-declaration for non-member at class scope" }
+};
diff --git a/gcc/testsuite/g++.dg/cpp1z/aggr-base8.C b/gcc/testsuite/g++.dg/cpp1z/aggr-base8.C
new file mode 100644
index 00000000000..8b495a80cb3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aggr-base8.C
@@ -0,0 +1,48 @@
+// PR c++/89214
+// { dg-do compile { target c++17 } }
+
+struct A
+{
+ A (int);
+};
+
+struct BB
+{
+ A a;
+};
+
+struct B : BB
+{
+};
+
+void
+foo ()
+{
+ B b1 = {42};
+ B b2 = {{42}};
+ B b3 = {{{42}}};
+
+ B b4 = B{42};
+ B b5 = B{{42}};
+ B b6 = B{{{42}}};
+
+ B b7 = {B{42}};
+ B b8 = {B{{42}}};
+ B b9 = {B{{{42}}}};
+
+ B b10 = {{B{42}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+ B b11 = {{B{{42}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+ B b12 = {{B{{{42}}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+
+ B bb1{42};
+ B bb2{{42}};
+ B bb3{{{42}}};
+
+ B bb7{B{42}};
+ B bb8{B{{42}}};
+ B bb9{B{{{42}}}};
+
+ B bb10{{B{42}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+ B bb11{{B{{42}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+ B bb12{{B{{{42}}}}}; // { dg-warning "initializing a base class of type .BB. results in object slicing" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C b/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
new file mode 100644
index 00000000000..56aa59cb64a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/aggr-base9.C
@@ -0,0 +1,33 @@
+// PR c++/89214
+// { dg-do compile { target c++17 } }
+
+struct B {
+ int c;
+};
+
+struct D : B { };
+
+void
+foo ()
+{
+ D d1 = {42};
+ D d2 = {{42}};
+
+ D d4 = D{42};
+ D d5 = D{{42}};
+
+ D d7 = {D{42}};
+ D d8 = {D{{42}}};
+
+ D d10 = {{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+ D d11 = {{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+
+ D dd1{42};
+ D dd2{{42}};
+
+ D dd7{D{42}};
+ D dd8{D{{42}}};
+
+ D dd10{{D{42}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+ D dd11{{D{{42}}}}; // { dg-warning "initializing a base class of type .B. results in object slicing" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/conv5.C b/gcc/testsuite/g++.dg/warn/conv5.C
new file mode 100644
index 00000000000..e238f9f30b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/conv5.C
@@ -0,0 +1,11 @@
+// PR c++/89876
+// { dg-do compile { target c++11 } }
+// { dg-prune-output "sorry" }
+
+template <typename T>
+T f (T, char*);
+
+template <typename T>
+decltype (f (T (), "")) g (T) { return ""; } // { dg-error "invalid conversion" }
+
+void h () { g (0); }
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 45bb87b3342..836ccd33b6e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,139 @@
+2019-05-07 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2019-02-06 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/89102 (partial)
+ * include/std/type_traits (common_type<>): Define.
+ (common_type<T>): Derive from common_type<T, T>.
+ * testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
+ Test zero-length template argument list.
+ * testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
+ Test additional single argument cases.
+ * testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
+ Adjust expected error.
+
+ Backport from mainline
+ 2019-01-22 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/88740
+ * testsuite/util/testsuite_hooks.h [stderr] (VERIFY): Use fprintf to
+ write to stderr instead of using printf.
+
+ Backport from mainline
+ 2019-04-23 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/90165
+ * include/std/variant (variant::__is_in_place_tag)
+ (variant::__not_in_place_tag): New helpers for variant(T&&)
+ constructor constraint.
+ (variant::variant(T&&)): Use __not_in_place_tag in constraints.
+ * testsuite/20_util/variant/compile.cc: Check variant(T&&) constructor
+ isn't used for in_place_type or in_place_index arguments.
+
+ Backport from mainline
+ 2019-04-17 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/90105
+ * include/bits/forward_list.tcc (operator==): Do not use operator!= to
+ compare elements.
+ (forward_list<T, A>::sort(Comp)): When elements are equal take the one
+ earlier in the list, so that sort is stable.
+ * testsuite/23_containers/forward_list/operations/90105.cc: New test.
+ * testsuite/23_containers/forward_list/comparable.cc: Test with
+ types that meet the minimum EqualityComparable and LessThanComparable
+ requirements. Remove irrelevant comment.
+
+ Backport from mainline
+ 2019-04-17 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/std/optional (optional::value_or(U&&) &&): Add missing
+ constexpr specifier.
+ * testsuite/20_util/optional/constexpr/observers/4.cc: Check value_or
+ for disengaged optionals and rvalue optionals.
+ * testsuite/20_util/optional/observers/4.cc: Likewise.
+
+ Backport from mainline
+ 2019-04-10 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/faq.xml: Add information about emergency EH pool.
+ * doc/xml/manual/debug.xml: Update list of memory debugging tools.
+ Move outdated information on mt_allocator to a separate section.
+ * doc/xml/manual/evolution.xml: Clarify that GLIBCXX_FORCE_NEW
+ doesn't affect the default allocator.
+
+ Backport from mainline
+ 2019-04-05 Jonathan Wakely <jwakely@redhat.com>
+
+ * src/filesystem/std-dir.cc (_Dir::advance(bool, error_code&)): Handle
+ d_type == DT_UNKNOWN immediately.
+ (_Dir::should_recurse(bool, error_code&)): Remove file_type::unknown
+ handling here.
+ * testsuite/27_io/filesystem/iterators/caching.cc: New test.
+
+ Backport from mainline
+ 2019-04-05 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/bits/fs_path.h (path::operator=(path&&)): Check for self
+ assignment.
+ * testsuite/27_io/filesystem/path/assign/copy.cc: Test self
+ assignment.
+
+ Backport from mainline
+ 2019-03-26 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/85965
+ * include/bits/hashtable.h (_Hashtable): Move static assertions to
+ destructor so they are not evaluated until the _Key type is complete.
+ * include/bits/stl_tree.h (_Rb_tree): Likewise.
+ * testsuite/23_containers/set/85965.cc: New test.
+ * testsuite/23_containers/unordered_set/85965.cc: New test.
+ * testsuite/23_containers/map/48101_neg.cc: Replace "here" errors
+ with regexp matching the corresponding _Rb_tree specialization.
+ * testsuite/23_containers/multimap/48101_neg.cc: Likewise.
+ * testsuite/23_containers/multiset/48101_neg.cc: Remove "here" error.
+ * testsuite/23_containers/set/48101_neg.cc: Likewise.
+ * testsuite/23_containers/unordered_map/48101_neg.cc: Likewise.
+ * testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise.
+ * testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
+ * testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.
+
+ Backport from mainline
+ 2019-03-11 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/89629
+ * libsupc++/hash_bytes.cc [__SIZEOF_SIZE_T__ == 8] (_Hash_bytes):
+ Use correct type for len_aligned.
+ * testsuite/20_util/hash/89629.cc: New test.
+
+ Backport from mainline
+ 2019-03-08 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/manual/using.xml: Use link element instead of xref.
+
+ Backport from mainline
+ 2019-02-14 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/manual/intro.xml: Document LWG 2586 status.
+ * include/bits/uses_allocator.h (__uses_alloc): Use const lvalue
+ allocator type in is_constructible checks.
+ * testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust dg-error.
+ * testsuite/20_util/scoped_allocator/dr2586.cc: New test.
+ * testsuite/20_util/tuple/cons/allocators.cc: Add test using
+ problematic type from LWG 2586 discussion.
+ * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error.
+ * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise.
+
+ Backport from mainline
+ 2019-02-14 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/manual/intro.xml: Document LWG 2537 status.
+ * include/bits/stl_queue.h
+ (priority_queue(const Compare&, const Container&, const Alloc&))
+ (priority_queue(const Compare&, Container&&, const Alloc&)): Call
+ make_heap.
+ * testsuite/23_containers/priority_queue/dr2537.cc: New test.
+
2019-02-22 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/89446
diff --git a/libstdc++-v3/doc/html/manual/using_macros.html b/libstdc++-v3/doc/html/manual/using_macros.html
index 7030bd2d0fd..dad6564a97d 100644
--- a/libstdc++-v3/doc/html/manual/using_macros.html
+++ b/libstdc++-v3/doc/html/manual/using_macros.html
@@ -116,7 +116,8 @@
enabled for
<code class="classname">std::vector&lt;T, std::allocator&lt;T&gt;&gt;</code>
and only when <code class="classname">std::allocator</code> is derived from
- <a class="xref" href="memory.html#allocator.impl" title="Implementation">the section called “Implementation”</a>. The annotations
+ <a class="link" href="memory.html#allocator.impl" title="Implementation"><code class="classname">new_allocator</code>
+ or <code class="classname">malloc_allocator</code></a>. The annotations
must be present on all vector operations or none, so this macro must
be defined to the same value for all translation units that create,
destroy or modify vectors.
diff --git a/libstdc++-v3/doc/xml/faq.xml b/libstdc++-v3/doc/xml/faq.xml
index edc07f16acb..b4bf333e26a 100644
--- a/libstdc++-v3/doc/xml/faq.xml
+++ b/libstdc++-v3/doc/xml/faq.xml
@@ -1001,21 +1001,31 @@
<qandaentry xml:id="faq.memory_leaks">
<question xml:id="q-memory_leaks">
<para>
- <quote>Memory leaks</quote> in containers
+ <quote>Memory leaks</quote> in libstdc++
</para>
</question>
<answer xml:id="a-memory_leaks">
- <note>
- <para>This answer is old and probably no longer be relevant.</para>
- </note>
<para>
- A few people have reported that the standard containers appear
+ Since GCC 5.1.0, libstdc++ automatically allocates a pool
+ of a few dozen kilobytes on startup. This pool is used to ensure it's
+ possible to throw exceptions (such as <classname>bad_alloc</classname>)
+ even when <code>malloc</code> is unable to allocate any more memory.
+ With some versions of <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://valgrind.org/"><command>valgrind</command></link>
+ this pool will be shown as "still reachable" when the process exits, e.g.
+ <code>still reachable: 72,704 bytes in 1 blocks</code>.
+ This memory is not a leak, because it's still in use by libstdc++,
+ and the memory will be returned to the OS when the process exits.
+ Later versions of <command>valgrind</command> know how to free this
+ pool as the process exits, and so won't show any "still reachable" memory.
+ </para>
+ <para>
+ In the past, a few people reported that the standard containers appear
to leak memory when tested with memory checkers such as
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://valgrind.org/"><command>valgrind</command></link>.
Under some (non-default) configurations the library's allocators keep
free memory in a
- pool for later reuse, rather than returning it to the OS. Although
- this memory is always reachable by the library and is never
+ pool for later reuse, rather than deallocating it with <code>delete</code>
+ Although this memory is always reachable by the library and is never
lost, memory debugging tools can report it as a leak. If you
want to test the library for memory leaks please read
<link linkend="debug.memory">Tips for memory leak hunting</link>
diff --git a/libstdc++-v3/doc/xml/manual/debug.xml b/libstdc++-v3/doc/xml/manual/debug.xml
index 37e330d3ed2..091e0b6914c 100644
--- a/libstdc++-v3/doc/xml/manual/debug.xml
+++ b/libstdc++-v3/doc/xml/manual/debug.xml
@@ -94,50 +94,35 @@
<section xml:id="debug.memory"><info><title>Memory Leak Hunting</title></info>
+<para>
+ On many targets GCC supports AddressSanitizer, a fast memory error detector,
+ which is enabled by the <option>-fsanitize=address</option> option.
+</para>
<para>
- There are various third party memory tracing and debug utilities
+ There are also various third party memory tracing and debug utilities
that can be used to provide detailed memory allocation information
about C++ code. An exhaustive list of tools is not going to be
attempted, but includes <code>mtrace</code>, <code>valgrind</code>,
- <code>mudflap</code>, and the non-free commercial product
- <code>purify</code>. In addition, <code>libcwd</code> has a
- replacement for the global new and delete operators that can track
- memory allocation and deallocation and provide useful memory
- statistics.
-</para>
-
-<para>
- Regardless of the memory debugging tool being used, there is one
- thing of great importance to keep in mind when debugging C++ code
- that uses <code>new</code> and <code>delete</code>: there are
- different kinds of allocation schemes that can be used by <code>
- std::allocator</code>. For implementation details, see the <link linkend="manual.ext.allocator.mt">mt allocator</link> documentation and
- look specifically for <code>GLIBCXX_FORCE_NEW</code>.
-</para>
-
-<para>
- In a nutshell, the optional <classname>mt_allocator</classname>
- is a high-performance pool allocator, and can
- give the mistaken impression that in a suspect executable, memory is
- being leaked, when in reality the memory "leak" is a pool being used
- by the library's allocator and is reclaimed after program
- termination.
+ <code>mudflap</code> (no longer supported since GCC 4.9.0), ElectricFence,
+ and the non-free commercial product <code>purify</code>.
+ In addition, <code>libcwd</code>, jemalloc and TCMalloc have replacements
+ for the global <code>new</code> and <code>delete</code> operators
+ that can track memory allocation and deallocation and provide useful
+ memory statistics.
</para>
<para>
For valgrind, there are some specific items to keep in mind. First
of all, use a version of valgrind that will work with current GNU
C++ tools: the first that can do this is valgrind 1.0.4, but later
- versions should work at least as well. Second of all, use a
- completely unoptimized build to avoid confusing valgrind. Third, use
- GLIBCXX_FORCE_NEW to keep extraneous pool allocation noise from
- cluttering debug information.
+ versions should work better. Second, using an unoptimized build
+ might avoid confusing valgrind.
</para>
<para>
- Fourth, it may be necessary to force deallocation in other libraries
- as well, namely the "C" library. On linux, this can be accomplished
+ Third, it may be necessary to force deallocation in other libraries
+ as well, namely the "C" library. On GNU/Linux, this can be accomplished
with the appropriate use of the <code>__cxa_atexit</code> or
<code>atexit</code> functions.
</para>
@@ -157,7 +142,6 @@
}
</programlisting>
-
<para>or, using <code>__cxa_atexit</code>:</para>
<programlisting>
@@ -184,6 +168,39 @@
valgrind -v --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes a.out
</programlisting>
+<section xml:id="debug.memory.mtalloc">
+<info><title>Non-memory leaks in Pool and MT allocators</title></info>
+
+<para>
+ There are different kinds of allocation schemes that can be used by
+ <code>std::allocator</code>. Prior to GCC 3.4.0 the default was to use
+ a pooling allocator, <classname>pool_allocator</classname>,
+ which is still available as the optional
+ <classname>__pool_alloc</classname> extension.
+ Another optional extension, <classname>__mt_alloc</classname>,
+ is a high-performance pool allocator.
+</para>
+
+<para>
+ In a suspect executable these pooling allocators can give
+ the mistaken impression that memory is being leaked,
+ when in reality the memory "leak" is a pool being used
+ by the library's allocator and is reclaimed after program
+ termination.
+</para>
+
+<para>
+ If you're using memory debugging tools on a program that uses
+ one of these pooling allocators, you can set the environment variable
+ <literal>GLIBCXX_FORCE_NEW</literal> to keep extraneous pool allocation
+ noise from cluttering debug information.
+ For more details, see the
+ <link linkend="manual.ext.allocator.mt">mt allocator</link>
+ documentation and look specifically for <code>GLIBCXX_FORCE_NEW</code>.
+</para>
+
+</section>
+
</section>
<section xml:id="debug.races"><info><title>Data Race Hunting</title></info>
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index 3288e2f6cf2..90b2f7b6f28 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -80,11 +80,12 @@ Removal of <filename class="headerfile">ext/tree</filename>, moved to <filename
<para> For GCC releases from 2.95 through the 3.1 series, defining
<literal>__USE_MALLOC</literal> on the gcc command line would change the
- default allocation strategy to instead use <code> malloc</code> and
- <function>free</function>. For the 3.2 and 3.3 release series the same
+ default allocation strategy to instead use <code>malloc</code> and
+ <code>free</code>. For the 3.2 and 3.3 release series the same
functionality was spelled <literal>_GLIBCXX_FORCE_NEW</literal>. From
- GCC 3.4 onwards the functionality is enabled by setting
- <literal>GLIBCXX_FORCE_NEW</literal> in the environment, see
+ GCC 3.4 onwards the default allocator uses <code>new</code> anyway,
+ but for the optional pooling allocators the functionality is enabled by
+ setting <literal>GLIBCXX_FORCE_NEW</literal> in the environment, see
<link linkend="manual.ext.allocator.mt">the mt allocator chapter</link>
for details.
</para>
diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml
index 71c2d8bbba0..66ad6e7062d 100644
--- a/libstdc++-v3/doc/xml/manual/intro.xml
+++ b/libstdc++-v3/doc/xml/manual/intro.xml
@@ -1105,6 +1105,14 @@ requirements of the license of GCC.
ill-formed.
</para></listitem></varlistentry>
+ <varlistentry xml:id="manual.bugs.dr2537"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2537">2537</link>:
+ <emphasis>Constructors for <code>priority_queue</code> taking allocators
+ should call <code>make_heap</code>
+ </emphasis>
+ </term>
+ <listitem><para>Call <code>make_heap</code>.
+ </para></listitem></varlistentry>
+
<varlistentry xml:id="manual.bugs.dr2583"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2583">2583</link>:
<emphasis>There is no way to supply an allocator for <code>basic_string(str, pos)</code>
</emphasis>
@@ -1112,6 +1120,14 @@ requirements of the license of GCC.
<listitem><para>Add new constructor
</para></listitem></varlistentry>
+ <varlistentry xml:id="manual.bugs.dr2586"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2586">2586</link>:
+ <emphasis>Wrong value category used in <code>scoped_allocator_adaptor::construct()</code>
+ </emphasis>
+ </term>
+ <listitem><para>Change internal helper for uses-allocator construction
+ to always check using const lvalue allocators.
+ </para></listitem></varlistentry>
+
<varlistentry xml:id="manual.bugs.dr2684"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#2684">2684</link>:
<emphasis><code>priority_queue</code> lacking comparator typedef
</emphasis>
diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml
index 873fac402b5..c9013c32d27 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -1130,8 +1130,8 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe
enabled for
<classname>std::vector&lt;T, std::allocator&lt;T&gt;&gt;</classname>
and only when <classname>std::allocator</classname> is derived from
- <xref linkend="allocator.impl"><classname>new_allocator</classname>
- or <classname>malloc_allocator</classname></xref>. The annotations
+ <link linkend="allocator.impl"><classname>new_allocator</classname>
+ or <classname>malloc_allocator</classname></link>. The annotations
must be present on all vector operations or none, so this macro must
be defined to the same value for all translation units that create,
destroy or modify vectors.
diff --git a/libstdc++-v3/include/bits/forward_list.tcc b/libstdc++-v3/include/bits/forward_list.tcc
index b41fbbb52f2..fb90e81c363 100644
--- a/libstdc++-v3/include/bits/forward_list.tcc
+++ b/libstdc++-v3/include/bits/forward_list.tcc
@@ -375,7 +375,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
auto __iy = __ly.cbegin();
while (__ix != __lx.cend() && __iy != __ly.cend())
{
- if (*__ix != *__iy)
+ if (!(*__ix == *__iy))
return false;
++__ix;
++__iy;
@@ -445,9 +445,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
__p = static_cast<_Node*>(__p->_M_next);
--__psize;
}
- else if (__comp(*__p->_M_valptr(), *__q->_M_valptr()))
+ else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr()))
{
- // First node of p is lower; e must come from p.
+ // First node of q is not lower; e must come from p.
__e = __p;
__p = static_cast<_Node*>(__p->_M_next);
--__psize;
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index fb85d489fd8..d9e18bfc30a 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -789,6 +789,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
inline path&
path::operator=(path&& __p) noexcept
{
+ if (&__p == this)
+ return *this;
+
_M_pathname = std::move(__p._M_pathname);
_M_cmpts = std::move(__p._M_cmpts);
_M_type = __p._M_type;
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index ba1d35dbecf..475cda6cac5 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -192,11 +192,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static_assert(is_same<typename _Alloc::value_type, _Value>{},
"unordered container must have the same value_type as its allocator");
#endif
- static_assert(__is_invocable<const _H1&, const _Key&>{},
- "hash function must be invocable with an argument of key type");
- static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{},
- "key equality predicate must be invocable with two arguments of "
- "key type");
using __traits_type = _Traits;
using __hash_cached = typename __traits_type::__hash_cached;
@@ -1373,6 +1368,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
clear();
_M_deallocate_buckets();
+
+ static_assert(__is_invocable<const _H1&, const _Key&>{},
+ "hash function must be invocable with an argument of key type");
+ static_assert(__is_invocable<const _Equal&, const _Key&, const _Key&>{},
+ "key equality predicate must be invocable with two arguments of "
+ "key type");
}
template<typename _Key, typename _Value,
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h
index 60116c1b49a..f6828def591 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -504,14 +504,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
priority_queue(const _Compare& __x, const _Alloc& __a)
: c(__a), comp(__x) { }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2537. Constructors [...] taking allocators should call make_heap
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const _Compare& __x, const _Sequence& __c,
const _Alloc& __a)
- : c(__c, __a), comp(__x) { }
+ : c(__c, __a), comp(__x)
+ { std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
- : c(std::move(__c), __a), comp(__x) { }
+ : c(std::move(__c), __a), comp(__x)
+ { std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
priority_queue(const priority_queue& __q, const _Alloc& __a)
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index d0a8448eb0b..fd96a63593a 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -448,17 +448,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits;
-#if __cplusplus >= 201103L
- static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
- "comparison object must be invocable with two arguments of key type");
-# if __cplusplus >= 201703L
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 2542. Missing const requirements for associative containers
- static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>,
- "comparison object must be invocable as const");
-# endif // C++17
-#endif // C++11
-
protected:
typedef _Rb_tree_node_base* _Base_ptr;
typedef const _Rb_tree_node_base* _Const_Base_ptr;
@@ -962,7 +951,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
~_Rb_tree() _GLIBCXX_NOEXCEPT
- { _M_erase(_M_begin()); }
+ {
+ _M_erase(_M_begin());
+
+#if __cplusplus >= 201103L
+ static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
+ "comparison object must be invocable "
+ "with two arguments of key type");
+# if __cplusplus >= 201703L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2542. Missing const requirements for associative containers
+ static_assert(is_invocable_v<const _Compare&, const _Key&, const _Key&>,
+ "comparison object must be invocable as const");
+# endif // C++17
+#endif // C++11
+ }
_Rb_tree&
operator=(const _Rb_tree& __x);
diff --git a/libstdc++-v3/include/bits/uses_allocator.h b/libstdc++-v3/include/bits/uses_allocator.h
index 820a2a59894..203758cfee3 100644
--- a/libstdc++-v3/include/bits/uses_allocator.h
+++ b/libstdc++-v3/include/bits/uses_allocator.h
@@ -83,14 +83,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc<true, _Tp, _Alloc, _Args...>
: conditional<
- is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value,
+ is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value,
__uses_alloc1<_Alloc>,
__uses_alloc2<_Alloc>>::type
{
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2586. Wrong value category used in scoped_allocator_adaptor::construct
static_assert(__or_<
- is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>,
- is_constructible<_Tp, _Args..., _Alloc>>::value, "construction with"
- " an allocator must be possible if uses_allocator is true");
+ is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>,
+ is_constructible<_Tp, _Args..., const _Alloc&>>::value,
+ "construction with an allocator must be possible"
+ " if uses_allocator is true");
};
template<typename _Tp, typename _Alloc, typename... _Args>
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional
index c40812f5e59..9f5d24e0220 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -1256,7 +1256,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _Up>
- _Tp
+ constexpr _Tp
value_or(_Up&& __u) &&
{
static_assert(is_move_constructible_v<_Tp>);
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 06c46ea312e..220f4991546 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2024,9 +2024,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __expanded_common_type_wrapper<__failure_type, _Args...>
{ typedef __failure_type type; };
+ template<>
+ struct common_type<>
+ { };
+
template<typename _Tp>
struct common_type<_Tp>
- { typedef typename decay<_Tp>::type type; };
+ : common_type<_Tp, _Tp>
+ { };
template<typename _Tp, typename _Up>
struct common_type<_Tp, _Up>
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 6cef89852ba..ee39c4fc001 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1076,6 +1076,17 @@ namespace __variant
using _Traits = __detail::__variant::_Traits<_Types...>;
+ template<typename _Tp>
+ struct __is_in_place_tag : false_type { };
+ template<typename _Tp>
+ struct __is_in_place_tag<in_place_type_t<_Tp>> : true_type { };
+ template<size_t _Np>
+ struct __is_in_place_tag<in_place_index_t<_Np>> : true_type { };
+
+ template<typename _Tp>
+ static constexpr bool __not_in_place_tag
+ = !__is_in_place_tag<decay_t<_Tp>>::value;
+
public:
variant() = default;
variant(const variant& __rhs) = default;
@@ -1087,6 +1098,7 @@ namespace __variant
template<typename _Tp,
typename = enable_if_t<!is_same_v<decay_t<_Tp>, variant>>,
typename = enable_if_t<(sizeof...(_Types)>0)>,
+ typename = enable_if_t<__not_in_place_tag<_Tp>>,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
&& is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>>>
constexpr
diff --git a/libstdc++-v3/libsupc++/hash_bytes.cc b/libstdc++-v3/libsupc++/hash_bytes.cc
index c6a563e76ba..ee8e2235818 100644
--- a/libstdc++-v3/libsupc++/hash_bytes.cc
+++ b/libstdc++-v3/libsupc++/hash_bytes.cc
@@ -139,7 +139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Remove the bytes not divisible by the sizeof(size_t). This
// allows the main loop to process the data as 64-bit integers.
- const int len_aligned = len & ~0x7;
+ const size_t len_aligned = len & ~(size_t)0x7;
const char* const end = buf + len_aligned;
size_t hash = seed ^ (len * mul);
for (const char* p = buf; p != end; p += 8)
diff --git a/libstdc++-v3/src/filesystem/std-dir.cc b/libstdc++-v3/src/filesystem/std-dir.cc
index 98eb22ab920..c14fa185974 100644
--- a/libstdc++-v3/src/filesystem/std-dir.cc
+++ b/libstdc++-v3/src/filesystem/std-dir.cc
@@ -57,7 +57,13 @@ struct fs::_Dir : _Dir_base
{
if (const auto entp = _Dir_base::advance(skip_permission_denied, ec))
{
- entry = fs::directory_entry{path / entp->d_name, get_file_type(*entp)};
+ file_type type = file_type::none;
+#ifdef _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE
+ // Even if the OS supports dirent::d_type the filesystem might not:
+ if (entp->d_type != DT_UNKNOWN)
+ type = get_file_type(*entp);
+#endif
+ entry = fs::directory_entry{path / entp->d_name, type};
return true;
}
else if (!ec)
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc
index 4a71021f2a0..08a317b95b6 100644
--- a/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc
@@ -30,6 +30,7 @@ namespace std
typedef void test_type5;
typedef const void test_type6;
+ template struct common_type<>;
template struct common_type<test_type1>;
template struct common_type<test_type1, test_type2>;
template struct common_type<test_type1, test_type2, test_type3>;
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
index 0907f9df24b..e933d5206b6 100644
--- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
+++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc
@@ -159,7 +159,10 @@ namespace std {
};
}
+static_assert(is_type<std::common_type<int>, int>(), "");
+static_assert(is_type<std::common_type<const int>, int>(), "");
static_assert(is_type<std::common_type<int, int>, int>(), "");
+static_assert(is_type<std::common_type<const int, int>, int>(), "");
static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn>(), "");
static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn>(), "");
static_assert(is_type<std::common_type<UnscEn, int>, int>(), "");
@@ -180,6 +183,8 @@ static_assert(is_type<std::common_type<int*, const volatile int*>,
const volatile int*>(), "");
static_assert(is_type<std::common_type<void*, const volatile int*>,
const volatile void*>(), "");
+static_assert(is_type<std::common_type<void>, void>(), "");
+static_assert(is_type<std::common_type<const void>, void>(), "");
static_assert(is_type<std::common_type<void, void>, void>(), "");
static_assert(is_type<std::common_type<const void, const void>, void>(), "");
static_assert(is_type<std::common_type<int&, int&&>, int>(), "");
@@ -316,6 +321,14 @@ static_assert(!has_type<std::common_type<UConv1, Abstract&&>>(), "");
static_assert(!has_type<std::common_type<std::initializer_list<int>,
std::initializer_list<long>>>(), "");
+// PR libstdc++/89102
+static_assert(!has_type<std::common_type<int() &>>(), "");
+static_assert(!has_type<std::common_type<int() & noexcept>>(), "");
+static_assert(!has_type<std::common_type<int() const>>(), "");
+static_assert(!has_type<std::common_type<int(...) &>>(), "");
+static_assert(!has_type<std::common_type<int(...) & noexcept>>(), "");
+static_assert(!has_type<std::common_type<int(...) const>>(), "");
+
void test(int i)
{
auto local_lmd1 = [=](int, double) { return i + i; };
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
index 8b0e9fd3f33..7758a7d08e5 100644
--- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
+++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc
@@ -25,7 +25,7 @@ template<typename... Args>
constexpr
std::array<typename std::common_type<Args...>::type,
sizeof...(Args)>
-make_array(Args&&... args) // { dg-error "invalid use" }
+make_array(Args&&... args) // { dg-error "no type.*common_type<>" }
{
typedef typename std::common_type<Args...>::type CT;
return std::array<CT, sizeof...(Args)>{static_cast<CT>
diff --git a/libstdc++-v3/testsuite/20_util/hash/89629.cc b/libstdc++-v3/testsuite/20_util/hash/89629.cc
new file mode 100644
index 00000000000..fd8273087fc
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/hash/89629.cc
@@ -0,0 +1,43 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target { lp64 || llp64 } } }
+// { dg-require-effective-target c++11 }
+// { dg-require-effective-target run_expensive_tests }
+
+#include <functional>
+#include <string>
+
+void
+test01()
+{
+ const std::size_t big = std::size_t(1) << 31;
+ std::string s;
+ try {
+ s.resize(big, 'a');
+ } catch (const std::bad_alloc&) {
+ return; // try to avoid a FAIL if memory allocation fails
+ }
+ // PR libstdc++/89629
+ (void) std::hash<std::string>{}(s);
+}
+
+int
+main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc b/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc
index 7743221adf7..12b0b9393c6 100644
--- a/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc
@@ -25,10 +25,42 @@ struct value_type
int i;
};
-int main()
+void test01()
{
constexpr std::optional<value_type> o { value_type { 51 } };
constexpr value_type fallback { 3 };
- static_assert( o.value_or(fallback).i == 51, "" );
- static_assert( o.value_or(fallback).i == (*o).i, "" );
+ static_assert( o.value_or(fallback).i == 51 );
+ static_assert( o.value_or(fallback).i == (*o).i );
+}
+
+void test02()
+{
+ constexpr std::optional<value_type> o;
+ constexpr value_type fallback { 3 };
+ static_assert( o.value_or(fallback).i == 3 );
+}
+
+template<typename T>
+ constexpr std::optional<value_type>
+ make_rvalue(T t)
+ { return std::optional<value_type>{t}; }
+
+void test03()
+{
+ constexpr value_type fallback { 3 };
+ static_assert( make_rvalue(value_type{51}).value_or(fallback).i == 51 );
+}
+
+void test04()
+{
+ constexpr value_type fallback { 3 };
+ static_assert( make_rvalue(std::nullopt).value_or(fallback).i == 3 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
}
diff --git a/libstdc++-v3/testsuite/20_util/optional/observers/4.cc b/libstdc++-v3/testsuite/20_util/optional/observers/4.cc
index ac8515f4cff..6f528b5c916 100644
--- a/libstdc++-v3/testsuite/20_util/optional/observers/4.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/observers/4.cc
@@ -26,10 +26,42 @@ struct value_type
int i;
};
-int main()
+void test01()
{
std::optional<value_type> o { value_type { 51 } };
value_type fallback { 3 };
VERIFY( o.value_or(fallback).i == 51 );
VERIFY( o.value_or(fallback).i == (*o).i );
}
+
+void test02()
+{
+ std::optional<value_type> o;
+ value_type fallback { 3 };
+ VERIFY( o.value_or(fallback).i == 3 );
+}
+
+void test03()
+{
+ std::optional<value_type> o { value_type { 51 } };
+ value_type fallback { 3 };
+ VERIFY( std::move(o).value_or(fallback).i == 51 );
+ VERIFY( o.has_value() );
+ VERIFY( std::move(o).value_or(fallback).i == (*o).i );
+}
+
+void test04()
+{
+ std::optional<value_type> o;
+ value_type fallback { 3 };
+ VERIFY( std::move(o).value_or(fallback).i == 3 );
+ VERIFY( !o.has_value() );
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+}
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
index 621ff47c7a3..3b2da30a065 100644
--- a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
@@ -46,5 +46,5 @@ test01()
scoped_alloc sa;
auto p = sa.allocate(1);
sa.construct(p); // this is required to be ill-formed
- // { dg-error "static assertion failed" "" { target *-*-* } 90 }
+ // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
}
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc
new file mode 100644
index 00000000000..11aab8a420b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <memory>
+#include <scoped_allocator>
+
+// DR 2586. Wrong value category used in scoped_allocator_adaptor::construct()
+
+struct X {
+ using allocator_type = std::allocator<X>;
+ X(std::allocator_arg_t, allocator_type&&) { }
+ X(const allocator_type&) { }
+};
+
+int main() {
+ std::scoped_allocator_adaptor<std::allocator<X>> sa;
+ sa.construct(sa.allocate(1));
+}
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc
index eb444f76cbe..85e43c9c16f 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc
@@ -181,9 +181,23 @@ void test02()
test_type empty = make_tuple();
}
+void test03()
+{
+ struct dr2586
+ {
+ using allocator_type = std::allocator<int>;
+ dr2586(std::allocator_arg_t, allocator_type&&) { }
+ dr2586(const allocator_type&) { }
+ };
+
+ const dr2586::allocator_type a;
+ std::tuple<dr2586> t{std::allocator_arg, a};
+}
+
int main()
{
test01();
test02();
+ test03();
return 0;
}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
index 348ed41a7bc..b1c6eab4c23 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
@@ -44,5 +44,5 @@ test01()
{
alloc_type a;
std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed
- // { dg-error "static assertion failed" "" { target *-*-* } 90 }
+ // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
index 8894e389cec..b0525d1f290 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
@@ -43,4 +43,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1);
}
-// { dg-error "static assertion failed" "" { target *-*-* } 90 }
+// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc
index 0b8eaf04b0d..811389a8fd7 100644
--- a/libstdc++-v3/testsuite/20_util/variant/compile.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc
@@ -129,10 +129,15 @@ void arbitrary_ctor()
static_assert(noexcept(variant<int, DefaultNoexcept>(DefaultNoexcept{})), "");
}
+struct none { none() = delete; };
+struct any { template <typename T> any(T&&) {} };
+
void in_place_index_ctor()
{
variant<string, string> a(in_place_index<0>, "a");
variant<string, string> b(in_place_index<1>, {'a'});
+
+ static_assert(!is_constructible_v<variant<none, any>, std::in_place_index_t<0>>, "PR libstdc++/90165");
}
void in_place_type_ctor()
@@ -140,6 +145,7 @@ void in_place_type_ctor()
variant<int, string, int> a(in_place_type<string>, "a");
variant<int, string, int> b(in_place_type<string>, {'a'});
static_assert(!is_constructible_v<variant<string, string>, in_place_type_t<string>, const char*>, "");
+ static_assert(!is_constructible_v<variant<none, any>, std::in_place_type_t<none>>, "PR libstdc++/90165");
}
void dtor()
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc
index aea2db96538..d7a50ee85f7 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc
@@ -17,15 +17,11 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-
-// NOTE: This makes use of the fact that we know how moveable
-// is implemented on list (via swap). If the implementation changed
-// this test may begin to fail.
-
#include <forward_list>
#include <testsuite_hooks.h>
-int main()
+void
+test01()
{
std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0};
std::forward_list<double> b = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
@@ -43,6 +39,40 @@ int main()
VERIFY((b > a) == true);
VERIFY((b >= a) == true);
VERIFY((b <= a) == false);
+}
+
+void
+test02()
+{
+ // The EqualityComparable requirements only require ==
+ struct X {
+ bool operator==(const X&) const { return true; }
+ };
+
+ std::forward_list<X> a(2);
+ const auto b = a;
+ VERIFY( a == b );
+}
+
+void
+test03()
+{
+ // The LessThanComparable requirements only require <
+ struct X {
+ bool operator<(const X&) const { return false; }
+ };
- return 0;
+ std::forward_list<X> a(2);
+ const auto b = a;
+ VERIFY( !(a < b) );
+ VERIFY( !(a > b) );
+ VERIFY( a <= b );
+ VERIFY( a >= b );
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc
new file mode 100644
index 00000000000..3c1478e2e34
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+
+// PR libstdc++/90105 - std::forward_list::sort() is not "stable"
+
+struct X
+{
+ int key;
+ int val;
+};
+
+bool operator<(const X& l, const X& r)
+{ return l.key < r.key; }
+
+bool operator==(const X& l, const X& r)
+{ return l.key == r.key && l.val == r.val; }
+
+void
+test01()
+{
+ std::forward_list<X> l{ {1, 1}, {2, 2}, {1, 3}, {0, 4}, {2, 5}, {0, 6} };
+ l.sort();
+ std::forward_list<X> exp{ {0, 4}, {0, 6}, {1, 1}, {1, 3}, {2, 2}, {2, 5} };
+ VERIFY( l == exp );
+}
+
+void
+test02()
+{
+ std::forward_list<X> l{ {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6} };
+ const std::forward_list<X> exp = l;
+ l.sort();
+ VERIFY( l == exp );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
index df913161bf3..9a63a0aa3c7 100644
--- a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc
@@ -23,8 +23,10 @@
void
test01()
{
- std::map<int, int, std::less<int*>> c; // { dg-error "here" }
- std::map<int, int, std::allocator<int>> c2; // { dg-error "here" }
+ std::map<int, int, std::less<int*>> c;
+ std::map<int, int, std::allocator<int>> c2;
}
+// { dg-error "_Compare = std::less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::allocator<int>" "" { target *-*-* } 0 }
// { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
index 5b4e335c91d..5b5f75d6d8c 100644
--- a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc
@@ -23,8 +23,10 @@
void
test01()
{
- std::multimap<int, int, std::less<int*>> c; // { dg-error "here" }
- std::multimap<int, int, std::allocator<int>> c2; // { dg-error "here" }
+ std::multimap<int, int, std::less<int*>> c;
+ std::multimap<int, int, std::allocator<int>> c2;
}
+// { dg-error "_Compare = std::less<int.>" "" { target *-*-* } 0 }
+// { dg-error "_Compare = std::allocator<int>" "" { target *-*-* } 0 }
// { dg-error "comparison object must be invocable" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc
index b815f86219b..b8f92b89bc0 100644
--- a/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc
@@ -23,7 +23,7 @@ void
test01()
{
std::multiset<const int> c; // { dg-error "here" }
- std::multiset<int, std::less<long*>> c2; // { dg-error "here" }
+ std::multiset<int, std::less<long*>> c2;
}
// { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc
new file mode 100644
index 00000000000..ecb51780ee5
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <queue>
+#include <testsuite_hooks.h>
+
+struct Q : std::priority_queue<int>
+{
+ using priority_queue::priority_queue;
+
+ bool is_heap() const
+ { return std::is_heap(c.begin(), c.end()); }
+};
+
+void
+test01()
+{
+ const Q::value_compare cmp;
+ const Q::container_type c{ 2, 3, 5, 7, 11, 13, 17, 19, 23 };
+ const Q::container_type::allocator_type a;
+
+ Q q1(cmp, c, a);
+ VERIFY( q1.is_heap() );
+
+ auto c2 = c;
+ Q q2(cmp, std::move(c2), a);
+ VERIFY( q2.is_heap() );
+}
+
+int
+main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc
index 9cd728d9bc6..c70c1779a76 100644
--- a/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc
@@ -23,7 +23,7 @@ void
test01()
{
std::set<const int> c; // { dg-error "here" }
- std::set<int, std::less<long*>> c2; // { dg-error "here" }
+ std::set<int, std::less<long*>> c2;
}
// { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/set/85965.cc b/libstdc++-v3/testsuite/23_containers/set/85965.cc
new file mode 100644
index 00000000000..54d501f6c4f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/85965.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <set>
+
+struct Base { };
+struct Derived; // derives from Base, but incomplete at this point
+
+struct Foo
+{
+ // PR libstdc++/85965
+ std::set<Derived*, std::less<Base*>> s;
+};
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc
index 956835c916a..17a7c88cddf 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc
@@ -23,7 +23,7 @@ void
test01()
{
using namespace std;
- unordered_map<int, int, equal_to<int>, hash<int>> c2; // { dg-error "here" }
+ unordered_map<int, int, equal_to<int>, hash<int>> c2;
}
// { dg-error "hash function must be invocable" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc
index ca717e313c6..309e43f71d6 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc
@@ -23,7 +23,7 @@ void
test01()
{
using namespace std;
- unordered_multimap<int, int, equal_to<int>, hash<int>> c2; // { dg-error "here" }
+ unordered_multimap<int, int, equal_to<int>, hash<int>> c2;
}
// { dg-error "hash function must be invocable" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc
index a06c302ad6b..223a8ebbf61 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc
@@ -24,7 +24,7 @@ test01()
{
using namespace std;
unordered_multiset<const int, hash<int>> c; // { dg-error "here" }
- unordered_multiset<int, equal_to<int>, hash<int>> c2; // { dg-error "here" }
+ unordered_multiset<int, equal_to<int>, hash<int>> c2;
}
// { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc
index 61f79f917e0..1a10286bb2b 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc
@@ -24,7 +24,7 @@ test01()
{
using namespace std;
unordered_set<const int, hash<int>> c; // { dg-error "here" }
- unordered_set<int, equal_to<int>, hash<int>> c2; // { dg-error "here" }
+ unordered_set<int, equal_to<int>, hash<int>> c2;
}
// { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc
new file mode 100644
index 00000000000..8b90b369901
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <unordered_set>
+
+struct Base { };
+struct Derived; // derives from Base, but incomplete at this point
+
+struct Foo
+{
+ // PR libstdc++/85965
+ std::unordered_set<Derived*, std::equal_to<Base*>, std::hash<Base*>> u;
+};
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc
new file mode 100644
index 00000000000..101b0cd6b49
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc
@@ -0,0 +1,76 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17 -lstdc++fs" }
+// { dg-do run { target c++17 } }
+// { dg-require-filesystem-ts "" }
+
+#include <filesystem>
+#include <testsuite_fs.h>
+#include <testsuite_hooks.h>
+
+namespace fs = std::filesystem;
+
+__gnu_test::scoped_file
+create_dir(fs::path dir = __gnu_test::nonexistent_path())
+{
+ fs::create_directory(dir);
+ return { dir, __gnu_test::scoped_file::adopt_file };
+}
+
+void
+test01()
+{
+ auto testdir = create_dir();
+ __gnu_test::scoped_file file1(testdir.path/"file1");
+ __gnu_test::scoped_file file2(testdir.path/"file2");
+
+ fs::directory_iterator it(testdir.path);
+ VERIFY( it->is_regular_file() );
+ ++it;
+ VERIFY( it->is_regular_file() );
+ ++it;
+ VERIFY( it == fs::directory_iterator{} );
+}
+
+void
+test02()
+{
+ auto testdir = create_dir();
+ const auto sub1 = create_dir(testdir.path/"sub1");
+ __gnu_test::scoped_file file1(sub1.path / "file");
+ const auto sub2 = create_dir(testdir.path/"sub2");
+ __gnu_test::scoped_file file2(sub2.path / "file");
+
+ fs::recursive_directory_iterator it(testdir.path);
+ VERIFY( it->is_directory() );
+ ++it;
+ VERIFY( it->is_regular_file() );
+ ++it;
+ VERIFY( it->is_directory() );
+ ++it;
+ VERIFY( it->is_regular_file() );
+ ++it;
+ VERIFY( it == fs::recursive_directory_iterator{} );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc
index e8391f46e2d..20d2d880f08 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc
@@ -21,6 +21,7 @@
#include <filesystem>
#include <testsuite_fs.h>
+#include <testsuite_hooks.h>
using std::filesystem::path;
using __gnu_test::compare_paths;
@@ -48,9 +49,26 @@ test02()
}
}
+void
+test03()
+{
+ // self assignment should have no effect
+ const path orig = "foo/bar/baz";
+ path p = orig;
+ const auto ptr1 = p.c_str();
+ const auto ptr2 = p.begin()->c_str();
+ p = std::move(p);
+ __gnu_test::compare_paths(p, orig);
+ p = p;
+ __gnu_test::compare_paths(p, orig);
+ VERIFY( ptr1 == p.c_str() );
+ VERIFY( ptr2 == p.begin()->c_str() );
+}
+
int
main()
{
test01();
test02();
+ test03();
}
diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h
index 36b53ac23f7..9700f0b7761 100644
--- a/libstdc++-v3/testsuite/util/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h
@@ -46,18 +46,25 @@
#include <bits/c++config.h>
#include <bits/functexcept.h>
#include <ctime>
+#include <stdio.h>
#ifdef _GLIBCXX_HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#ifdef stderr
+# define _VERIFY_PRINT(S, F, L, P, C) __builtin_fprintf(stderr, S, F, L, P, C)
+#else
+# define _VERIFY_PRINT(S, F, L, P, C) __builtin_printf(S, F, L, P, C)
+#endif
+
#define VERIFY(fn) \
do \
{ \
if (! (fn)) \
{ \
- __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", \
- __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \
+ _VERIFY_PRINT("%s:%d: %s: Assertion '%s' failed.\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \
__builtin_abort(); \
} \
} while (false)