]>
Commit | Line | Data |
---|---|---|
0349df29 BK |
1 | // 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
538075fe PC |
3 | // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
4 | // Free Software Foundation, Inc. | |
0349df29 BK |
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. | |
11 | ||
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. | |
16 | ||
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 | |
83f51799 | 19 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
0349df29 BK |
20 | // USA. |
21 | ||
22 | // 19.1 Exception classes | |
23 | ||
24 | #include <string> | |
25 | #include <stdexcept> | |
538075fe | 26 | #include <cstring> |
fe413112 | 27 | #include <testsuite_hooks.h> |
0349df29 | 28 | |
5e984b90 | 29 | // test copy ctors, assignment operators, and persistence of member string data |
9dd3d53c BK |
30 | // libstdc++/1972 |
31 | // via Greg Bumgardner <bumgard@roguewave.com> | |
32 | void allocate_on_stack(void) | |
33 | { | |
34 | const size_t num = 512; | |
35 | __extension__ char array[num]; | |
36 | for (size_t i = 0; i < num; i++) | |
37 | array[i]=0; | |
38 | } | |
5e984b90 | 39 | |
9dd3d53c BK |
40 | void test04() |
41 | { | |
11f10e6b | 42 | bool test __attribute__((unused)) = true; |
9dd3d53c BK |
43 | const std::string s("CA ISO emergency once again:immediate power down"); |
44 | const char* strlit1 = "wish I lived in Palo Alto"; | |
45 | const char* strlit2 = "...or Santa Barbara"; | |
46 | std::runtime_error obj1(s); | |
47 | ||
48 | // block 01 | |
49 | { | |
50 | const std::string s2(strlit1); | |
51 | std::runtime_error obj2(s2); | |
52 | obj1 = obj2; | |
53 | } | |
54 | allocate_on_stack(); | |
eeff8d2c | 55 | VERIFY( std::strcmp(strlit1, obj1.what()) == 0 ); |
9dd3d53c BK |
56 | |
57 | // block 02 | |
58 | { | |
59 | const std::string s3(strlit2); | |
60 | std::runtime_error obj3 = std::runtime_error(s3); | |
61 | obj1 = obj3; | |
62 | } | |
63 | allocate_on_stack(); | |
eeff8d2c | 64 | VERIFY( std::strcmp(strlit2, obj1.what()) == 0 ); |
9dd3d53c | 65 | } |
0349df29 BK |
66 | |
67 | int main(void) | |
68 | { | |
9dd3d53c | 69 | test04(); |
0349df29 BK |
70 | return 0; |
71 | } |