Merge from mainline (160224:163495).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / 27_io / ios_base / failure / what-3.cc
blobddb29c5efc7190b71bbe21106d19c31a0c2db415
1 // 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
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 3, 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 COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 19.1 Exception classes
23 #include <string>
24 #include <ios>
25 #include <cstring>
26 #include <testsuite_hooks.h>
28 // test copy ctors, assignment operators, and persistence of member string data
29 // libstdc++/1972
30 // via Greg Bumgardner <bumgard@roguewave.com>
31 void allocate_on_stack(void)
33 const size_t num = 512;
34 __extension__ char array[num];
35 for (size_t i = 0; i < num; i++)
36 array[i]=0;
37 for (size_t i = 0; i < num; i++)
38 array[i]=array[i]; // Suppress unused warning.
41 void test04()
43 bool test __attribute__((unused)) = true;
44 const std::string s("CA ISO emergency once again:immediate power down");
45 const char* strlit1 = "wish I lived in Palo Alto";
46 const char* strlit2 = "...or Santa Barbara";
47 std::ios_base::failure obj1(s);
49 // block 01
51 const std::string s2(strlit1);
52 std::ios_base::failure obj2(s2);
53 obj1 = obj2;
55 allocate_on_stack();
56 VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
58 // block 02
60 const std::string s3(strlit2);
61 std::ios_base::failure obj3 = std::ios_base::failure(s3);
62 obj1 = obj3;
64 allocate_on_stack();
65 VERIFY( std::strcmp(strlit2, obj1.what()) == 0 );
68 int main(void)
70 test04();
71 return 0;