]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/18_support/numeric_limits/traps.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 18_support / numeric_limits / traps.cc
CommitLineData
d35c8bb5 1// { dg-add-options ieee }
720e2f72 2
aa118a03 3// Copyright (C) 2005-2014 Free Software Foundation, Inc.
720e2f72
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
720e2f72
BK
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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
720e2f72
BK
19
20// 18.2.1.1 template class numeric_limits
21
22#include <limits>
23#include <testsuite_hooks.h>
24
25template<typename T>
26 void
e7c59a0e 27 test_traps(T r = T(0))
720e2f72
BK
28 {
29 typedef T value_type;
30 volatile value_type i(5);
31 volatile value_type j(0);
32
33 if (!std::numeric_limits<value_type>::traps)
e7c59a0e 34 r = i / j;
720e2f72
BK
35 }
36
37// libstdc++/22203
38int main()
39{
40 test_traps<int>();
41 test_traps<unsigned int>();
42 test_traps<long>();
43 test_traps<unsigned long>();
44 test_traps<long long>();
45 test_traps<unsigned long long>();
46
47 /*
48 For floating points, trapping is a different, more complicated
49 story. If is_iecxxx is true, then division by zero would not trap
50 (infinity). If is_iecxxx is false, we don't know (VAX may trap for
51 0/0 -- I have to check). For most cases (i.e. IEE-754), trapping
52 for floating points have to do with whether there is a support for
53 signaling NaN.
54 - Gaby.
55 */
56 // test_traps<float>();
57 // test_traps<double>();
58 // test_traps<long double>();
59
60 return 0;
61}