Re: Fix Debug insert_return_type

2017-12-18 Thread Jonathan Wakely
On 15 December 2017 at 21:19, François Dumont wrote:
> Here is a patch to fix those failures of the latest report:
>
> UNRESOLVED: 23_containers/map/modifiers/extract.cc compilation failed to
> produce executable
> FAIL: 23_containers/set/modifiers/extract.cc (test for excess errors)
> UNRESOLVED: 23_containers/set/modifiers/extract.cc compilation failed to
> produce executable
> FAIL: 23_containers/unordered_map/modifiers/extract.cc (test for excess
> errors)
> UNRESOLVED: 23_containers/unordered_map/modifiers/extract.cc compilation
> failed to produce executable
> FAIL: 23_containers/unordered_set/modifiers/extract.cc (test for excess
> errors)
> UNRESOLVED: 23_containers/unordered_set/modifiers/extract.cc compilation
> failed to produce executable
>
>
> Tested under Linux x86_64 Debug mode.
>
> Ok to commit ?

OK, thanks for fixing it.


> Note that I don't understand this in _Rb_tree:
>
>   using insert_return_type = _Node_insert_return<
> conditional_t, const_iterator, iterator>,
> node_type>;
>
> Why the conditional_t part ? In Debug mode it is always using iterator and I
> don't understand what represent this is_same_v<_Key, _Val> condition.

is_same_v<_Keym _Val> is true for sets, false for maps.

The condition means that the type uses _Rb_tree<>::const_iterator for
sets, and _Rb_tree::iterator for maps. IIRC this is necessary because
set::iterator is a typedef for set::const_iterator and that can only
constructed from _Rb_tree<>::const_iterator, not from
_Rb_tree<>::iterator. So for sets the member of _Rb_tree needs to
return a const_iterator.

There is no _Rb_tree::insert_return_type in Debug Mode, so you're
comparing apples and oranges. The iterator in Debug Mode is either
set::iterator (which is the same as set::const_iterator) or
map::iterator, not _Rb_tree::iterator.


Fix Debug insert_return_type

2017-12-15 Thread François Dumont

Here is a patch to fix those failures of the latest report:

UNRESOLVED: 23_containers/map/modifiers/extract.cc compilation failed to 
produce executable
FAIL: 23_containers/set/modifiers/extract.cc (test for excess errors)
UNRESOLVED: 23_containers/set/modifiers/extract.cc compilation failed to 
produce executable
FAIL: 23_containers/unordered_map/modifiers/extract.cc (test for excess errors)
UNRESOLVED: 23_containers/unordered_map/modifiers/extract.cc compilation failed 
to produce executable
FAIL: 23_containers/unordered_set/modifiers/extract.cc (test for excess errors)
UNRESOLVED: 23_containers/unordered_set/modifiers/extract.cc compilation failed 
to produce executable


Tested under Linux x86_64 Debug mode.

Ok to commit ?

Note that I don't understand this in _Rb_tree:

  using insert_return_type = _Node_insert_return<
conditional_t, const_iterator, iterator>,
node_type>;

Why the conditional_t part ? In Debug mode it is always using iterator and I don't 
understand what represent this is_same_v<_Key, _Val> condition.

François

diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h
index 99d0623..4844a62 100644
--- a/libstdc++-v3/include/debug/map.h
+++ b/libstdc++-v3/include/debug/map.h
@@ -401,13 +401,7 @@ namespace __debug
 
 #if __cplusplus > 201402L
   using node_type = typename _Base::node_type;
-
-  struct insert_return_type
-  {
-	bool inserted;
-	iterator position;
-	node_type node;
-  };
+  using insert_return_type = _Node_insert_return;
 
   node_type
   extract(const_iterator __position)
@@ -431,7 +425,7 @@ namespace __debug
   {
 	auto __ret = _Base::insert(std::move(__nh));
 	iterator __pos = iterator(__ret.position, this);
-	return { __ret.inserted, __pos, std::move(__ret.node) };
+	return { __pos, __ret.inserted, std::move(__ret.node) };
   }
 
   iterator
diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h
index 5353cfe..4466bfc 100644
--- a/libstdc++-v3/include/debug/set.h
+++ b/libstdc++-v3/include/debug/set.h
@@ -298,13 +298,7 @@ namespace __debug
 
 #if __cplusplus > 201402L
   using node_type = typename _Base::node_type;
-
-  struct insert_return_type
-  {
-	bool inserted;
-	iterator position;
-	node_type node;
-  };
+  using insert_return_type = _Node_insert_return;
 
   node_type
   extract(const_iterator __position)
@@ -328,7 +322,7 @@ namespace __debug
   {
 	auto __ret = _Base::insert(std::move(__nh));
 	iterator __pos = iterator(__ret.position, this);
-	return { __ret.inserted, __pos, std::move(__ret.node) };
+	return { __pos, __ret.inserted, std::move(__ret.node) };
   }
 
   iterator
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map
index c68ccaa..0ed9922 100644
--- a/libstdc++-v3/include/debug/unordered_map
+++ b/libstdc++-v3/include/debug/unordered_map
@@ -462,13 +462,7 @@ namespace __debug
 
 #if __cplusplus > 201402L
   using node_type = typename _Base::node_type;
-
-  struct insert_return_type
-  {
-	bool inserted;
-	iterator position;
-	node_type node;
-  };
+  using insert_return_type = _Node_insert_return;
 
   node_type
   extract(const_iterator __position)
@@ -499,7 +493,7 @@ namespace __debug
   {
 	auto __ret = _Base::insert(std::move(__nh));
 	iterator __pos = iterator(__ret.position, this);
-	return { __ret.inserted, __pos, std::move(__ret.node) };
+	return { __pos, __ret.inserted, std::move(__ret.node) };
   }
 
   iterator
diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set
index 1fe493f..1f8e95f 100644
--- a/libstdc++-v3/include/debug/unordered_set
+++ b/libstdc++-v3/include/debug/unordered_set
@@ -372,13 +372,7 @@ namespace __debug
 
 #if __cplusplus > 201402L
   using node_type = typename _Base::node_type;
-
-  struct insert_return_type
-  {
-	bool inserted;
-	iterator position;
-	node_type node;
-  };
+  using insert_return_type = _Node_insert_return;
 
   node_type
   extract(const_iterator __position)
@@ -409,7 +403,7 @@ namespace __debug
   {
 	auto __ret = _Base::insert(std::move(__nh));
 	iterator __pos = iterator(__ret.position, this);
-	return { __ret.inserted, __pos, std::move(__ret.node) };
+	return { __pos, __ret.inserted, std::move(__ret.node) };
   }
 
   iterator