On 25/03/21 4:29 pm, Jonathan Wakely wrote:
Oh, it's the same generate(sz) bug as you already found. But I've
found other bugs, e.g. with GLIBCXX_SEED_TEST_RNG=1908970375).
I think we should also add a check for non-empty containers to those
test functions, and ensure we don't try to erase from empty
containers (see attached).
I had a look at this patch and on my side I was more thinking about
avoiding empty containers in the first place.
What do you think ?
François
diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h
index 54449d2f7bb..6940f2f765d 100644
--- a/libstdc++-v3/testsuite/util/exception/safety.h
+++ b/libstdc++-v3/testsuite/util/exception/safety.h
@@ -55,14 +55,14 @@ namespace __gnu_test
// Return randomly generated integer on range [0, __max_size].
static size_type
- generate(size_type __max_size)
+ generate(size_type __max_size, size_type __min_size = 0)
{
using param_type = typename distribution_type::param_type;
// Make the engine and distribution static...
static engine_type engine = get_engine();
static distribution_type distribution;
- return distribution(engine, param_type{0, __max_size});
+ return distribution(engine, param_type{__min_size, __max_size});
}
// Given an instantiating type, return a unique value.
@@ -198,7 +198,8 @@ namespace __gnu_test
// Size test container.
const size_type max_elements = 100;
- size_type n = generate(max_elements);
+ const size_type min_elements = 10;
+ size_type n = generate(max_elements, min_elements);
// Construct new container.
make_container_n<container_type> made(n);