stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r332641 - /incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp
Date Fri, 11 Nov 2005 20:33:12 GMT
Author: sebor
Date: Fri Nov 11 12:33:09 2005
New Revision: 332641

URL: http://svn.apache.org/viewcvs?rev=332641&view=rev
Log:
2005-11-11  Martin Sebor  <sebor@roguewave.com>

	* 18.limits.traps.cpp: Used Structured Exception Handling on Windows.
	Removed the unnecessary SIGTRAP handler (integer division by zero
	typically causes SIGFPE).

Modified:
    incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp

Modified: incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp?rev=332641&r1=332640&r2=332641&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp (original)
+++ incubator/stdcxx/trunk/tests/support/18.limits.traps.cpp Fri Nov 11 12:33:09 2005
@@ -22,7 +22,7 @@
 #include <limits>
 
 #include <csetjmp>   // for longjmp, setjmp
-#include <csignal>   // for SIGFPE, SIGTRAP, signal
+#include <csignal>   // for SIGFPE, signal
 
 #include <driver.h>
 
@@ -37,42 +37,40 @@
     std::longjmp (jmp_env, 1);
 }
 
-void handle_trap (int)
-{
-    std::longjmp (jmp_env, 1);
-}
-
 }   // extern "C"
 
 /**************************************************************************/
 
+#ifdef _MSC_VER
+   // silence useless MSVC warnings:
+   // 4800: 'int' : forcing value to bool 'true' or 'false'
+   // 4804: '/' : unsafe use of type 'bool' in operation
+#  pragma warning (disable: 4800 4804)
+
+   // use Structured Exception Handling to detect arithmetic exceptions
+#  define TRY           __try
+#  define EXCEPT(arg)   __except (arg)
+#else
+#  define TRY              if (1)
+#  define EXCEPT(ignore)   else if (0)
+#endif   // _MSC_VER
+
+
 template <class numT>
-numT test_traps (numT, const char *tname, int lineno, bool floating)
+numT test_traps (numT, const char *tname, int lineno, bool)
 {
     const bool traps = std::numeric_limits<numT>::traps;
 
-    _RWSTD_UNUSED (floating);
-
 #ifdef SIGFPE
     std::signal (SIGFPE, handle_fpe);
 #else   // if !defined (SIGFPE)
-    if (!rw_warn (!traps || !floating, 0, lineno,
+    if (!rw_warn (!traps, 0, lineno,
                   "SIGFPE not #defined and numeric_limits<%s>::traps == true, "
                   "cannot test", tname)) {
         return numT ();
     }
 #endif   // SIGFPE
 
-#ifdef SIGTRAP
-    std::signal (SIGTRAP, handle_trap);
-#else   // if !defined (SIGTRAP)
-    if (!rw_warn (!traps || floating, 0, lineno,
-                  "SIGTRAP not #defined and numeric_limits<%s>::traps == true, "
-                  "cannot test", tname)) {
-        return numT ();
-    }
-#endif   // SIGTRAP
-
     numT result = numT ();
 
     const int jumped = setjmp (jmp_env);
@@ -88,7 +86,12 @@
         trapped = true;
     }
     else {
-        result = one / zero;
+        TRY {
+            result = one / zero;
+        }
+        EXCEPT (1) {
+            trapped = true;
+        }
     }
 
     rw_assert (trapped == traps, 0, lineno,



Mime
View raw message