Howard Hinnant | aafd08a | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 1 | //===---------------------- catch_array_01.cpp ----------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // Can you have a catch clause of array type that catches anything? |
| 11 | |
Eric Fiselier | e65dd84 | 2016-01-20 04:06:46 +0000 | [diff] [blame] | 12 | // GCC incorrectly allows array types to be caught by reference. |
| 13 | // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372 |
| 14 | // XFAIL: gcc |
Asiri Rathnayake | 4174e8b | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 15 | // UNSUPPORTED: libcxxabi-no-exceptions |
Eric Fiselier | e65dd84 | 2016-01-20 04:06:46 +0000 | [diff] [blame] | 16 | |
Howard Hinnant | aafd08a | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 17 | #include <cassert> |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | typedef char Array[4]; |
| 22 | Array a = {'H', 'i', '!', 0}; |
| 23 | try |
| 24 | { |
| 25 | throw a; // converts to char* |
| 26 | assert(false); |
| 27 | } |
| 28 | catch (Array& b) // can't catch char* |
| 29 | { |
| 30 | assert(false); |
| 31 | } |
| 32 | catch (...) |
| 33 | { |
| 34 | } |
| 35 | } |