Brian Silverman | a6f7ce0 | 2018-07-07 15:04:00 -0700 | [diff] [blame^] | 1 | ///////////////////////////////////////////////////////////////////////////////
|
| 2 | //
|
| 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
| 4 | //
|
| 5 | // This code is licensed under the MIT License (MIT).
|
| 6 | //
|
| 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 13 | // THE SOFTWARE.
|
| 14 | //
|
| 15 | ///////////////////////////////////////////////////////////////////////////////
|
| 16 |
|
| 17 | #include <cstdlib> // for std::exit
|
| 18 | #include <gsl/span> // for span
|
| 19 |
|
| 20 | int operator_subscript_no_throw()
|
| 21 | {
|
| 22 | int arr[10];
|
| 23 | gsl::span<int> sp { arr };
|
| 24 | return sp[11];
|
| 25 | }
|
| 26 |
|
| 27 |
|
| 28 | void test_terminate()
|
| 29 | {
|
| 30 | std::exit(0);
|
| 31 | }
|
| 32 |
|
| 33 | void setup_termination_handler()
|
| 34 | {
|
| 35 | #if defined(_MSC_VER)
|
| 36 |
|
| 37 | auto& handler = gsl::details::get_terminate_handler();
|
| 38 | handler = &test_terminate;
|
| 39 |
|
| 40 | #else
|
| 41 |
|
| 42 | std::set_terminate(test_terminate);
|
| 43 |
|
| 44 | #endif
|
| 45 | }
|
| 46 |
|
| 47 |
|
| 48 | int main()
|
| 49 | {
|
| 50 | setup_termination_handler();
|
| 51 | operator_subscript_no_throw();
|
| 52 | return -1;
|
| 53 | }
|