Update concepts branch to revision 131834
[official-gcc.git] / libstdc++-v3 / testsuite / 19_diagnostics / system_error / what-3.cc
blob76d10b8e8281f39e22fb36128a3034f13f662ca6
1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2007
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 #include <string>
23 #include <system_error>
24 #include <cstring>
25 #include <testsuite_hooks.h>
27 // test copy ctors, assignment operators, and persistence of member string data
28 // libstdc++/1972
29 // via Greg Bumgardner <bumgard@roguewave.com>
30 void allocate_on_stack(void)
32 const size_t num = 512;
33 __extension__ char array[num];
34 for (size_t i = 0; i < num; i++)
35 array[i]=0;
38 void test04()
40 bool test __attribute__((unused)) = true;
41 const std::string s("CA ISO emergency once again:immediate power down");
42 const char* strlit1 = "wish I lived in Palo Alto";
43 const char* strlit2 = "...or Santa Barbara";
44 std::system_error obj1(std::error_code(), s);
46 // block 01
48 const std::string s2(strlit1);
49 std::system_error obj2(std::error_code(), s2);
50 obj1 = obj2;
52 allocate_on_stack();
53 VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
55 // block 02
57 const std::string s3(strlit2);
58 std::system_error obj3 = std::system_error(std::error_code(), s3);
59 obj1 = obj3;
61 allocate_on_stack();
62 VERIFY( std::strcmp(strlit2, obj1.what()) == 0 );
65 int main(void)
67 test04();
68 return 0;