]>
Commit | Line | Data |
---|---|---|
0349df29 BK |
1 | // 2001-02-26 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
8339896e | 3 | // Copyright (C) 2001, 2002 Free Software Foundation, Inc. |
0349df29 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 2, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING. If not, write to the Free | |
83f51799 | 18 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
0349df29 BK |
19 | // USA. |
20 | ||
21 | // 19.1 Exception classes | |
22 | ||
23 | #include <string> | |
24 | #include <stdexcept> | |
fe413112 | 25 | #include <testsuite_hooks.h> |
0349df29 | 26 | |
9dd3d53c BK |
27 | // test copy ctors and assignment operators |
28 | // libstdc++/1972 | |
29 | // via Greg Bumgardner <bumgard@roguewave.com> | |
30 | void allocate_on_stack(void) | |
31 | { | |
32 | const size_t num = 512; | |
33 | __extension__ char array[num]; | |
34 | for (size_t i = 0; i < num; i++) | |
35 | array[i]=0; | |
36 | } | |
37 | void test04() | |
38 | { | |
11f10e6b | 39 | bool test __attribute__((unused)) = true; |
9dd3d53c BK |
40 | const std::string s("CA ISO emergency once again:immediate power down"); |
41 | const char* strlit1 = "wish I lived in Palo Alto"; | |
42 | const char* strlit2 = "...or Santa Barbara"; | |
43 | std::runtime_error obj1(s); | |
44 | ||
45 | // block 01 | |
46 | { | |
47 | const std::string s2(strlit1); | |
48 | std::runtime_error obj2(s2); | |
49 | obj1 = obj2; | |
50 | } | |
51 | allocate_on_stack(); | |
eeff8d2c | 52 | VERIFY( std::strcmp(strlit1, obj1.what()) == 0 ); |
9dd3d53c BK |
53 | |
54 | // block 02 | |
55 | { | |
56 | const std::string s3(strlit2); | |
57 | std::runtime_error obj3 = std::runtime_error(s3); | |
58 | obj1 = obj3; | |
59 | } | |
60 | allocate_on_stack(); | |
eeff8d2c | 61 | VERIFY( std::strcmp(strlit2, obj1.what()) == 0 ); |
9dd3d53c | 62 | } |
0349df29 BK |
63 | |
64 | int main(void) | |
65 | { | |
9dd3d53c | 66 | test04(); |
0349df29 BK |
67 | return 0; |
68 | } |