]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/21_strings/basic_string/pthread18185.cc
Simplify dg-options for tests using pthreads
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / pthread18185.cc
CommitLineData
c137586a 1//
818ab71a 2// Copyright (C) 2004-2016 Free Software Foundation, Inc.
c137586a
MV
3//
4// This file is part of the GNU ISO C++ Library. This library is free
5// software; you can redistribute it and/or modify it under the
6// terms of the GNU General Public License as published by the
748086b7 7// Free Software Foundation; either version 3, or (at your option)
c137586a
MV
8// any later version.
9//
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License along
748086b7
JJ
16// with this library; see the file COPYING3. If not see
17// <http://www.gnu.org/licenses/>.
c137586a 18
37d13ae6 19// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-rtems* *-*-darwin* } }
71c54f8e 20// { dg-options "-pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* } }
c137586a
MV
21
22#include <ext/new_allocator.h>
23#include <string>
24#include <pthread.h>
25
e7c59a0e
PC
26static void*
27foo (void*)
c137586a
MV
28{
29 typedef std::char_traits<char> traits_type;
30 typedef __gnu_cxx::new_allocator<char> allocator_type;
31 typedef std::basic_string<char, traits_type, allocator_type> string_type;
32 try
33 {
34 throw string_type("leak");
35 }
36 catch (const string_type&)
37 {
38 pthread_exit (0);
39 }
40}
41
42// c++/18185
43// This used to leak memory.
44int
45main ()
46{
47 pthread_t t;
e7c59a0e
PC
48 pthread_create (&t, 0, foo, 0);
49 pthread_join (t, 0);
c137586a
MV
50 return 0;
51}