GCC Bugzilla – Attachment 31049 Details for
Bug 58800
[4.7/4.8/4.9 Regression] std::nth_element segfaults on valid input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
random test
random_test.cc (text/x-c++src), 1.91 KB, created by
Chris Jefferson
on 2013-10-19 08:54:47 UTC
(
hide
)
Description:
random test
Filename:
MIME Type:
Creator:
Chris Jefferson
Created:
2013-10-19 08:54:47 UTC
Size:
1.91 KB
patch
obsolete
>// Copyright (C) 2005-2013 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++11" } > >// 25.3.2 [lib.alg.nth.element] > >#include <algorithm> >#include <testsuite_hooks.h> >#include <testsuite_iterators.h> >#include <random> > > >using __gnu_test::test_container; >using __gnu_test::random_access_iterator_wrapper; >using std::nth_element; >using std::partial_sort; > >std::mt19937_64 random_gen; > >typedef test_container<int, random_access_iterator_wrapper> Container; > >bool test __attribute__((unused)) = true; > >void >test_domain_size(int length, int domain) >{ > std::vector<int> values; > for(int i = 0; i < length; ++i) > { > values.push_back(random_gen() % domain); > } > > std::vector<int> clone(values); > int element = random_gen() % length; > Container con(values.data(), values.data() + length); > > nth_element(con.begin(), con.begin() + element, con.end()); > > for(int i = 0; i < element; ++i) > { > VERIFY(values[i] <= values[element]); > } > for(int i = element + 1; i < length; ++i) > { > VERIFY(values[i] >= values[element]); > } >} > > >int >main() >{ > for(int i = 0; i < 100000; ++i) > { > test_domain_size(10, 10); > test_domain_size(100, 10000); > test_domain_size(1000, 100); > test_domain_size(1000, 10); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 58800
:
31047
|
31049
|
31051