You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by vi...@apache.org on 2008/05/30 23:24:06 UTC

svn commit: r661873 - /stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp

Author: vitek
Date: Fri May 30 14:24:06 2008
New Revision: 661873

URL: http://svn.apache.org/viewvc?rev=661873&view=rev
Log:
2008-05-30  Travis Vitek  <vi...@roguewave.com>

	STDCXX-833
	* tests/regress/18.limits.traps.stdcxx-624.cpp: Add special
	handling for divide by zero on windows.

Modified:
    stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp

Modified: stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp?rev=661873&r1=661872&r2=661873&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp (original)
+++ stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp Fri May 30 14:24:06 2008
@@ -2,7 +2,7 @@
  *
  * 18.limits.traps.stdcxx-624.cpp - regression test for STDCXX-624
  *
- * $Id:$
+ * $Id$
  *
  ***************************************************************************
  *
@@ -50,6 +50,16 @@
 }   // extern "C"
 
 
+#ifdef _MSC_VER
+   // 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
+
+
 int main ()
 {
     // prevent clever optimizers from figuring out that (zero == 0)
@@ -66,14 +76,21 @@
     if (std::numeric_limits<int>::traps)
         std::signal (SIGFPE, handle_FPE);
 
+    bool trapped = false;
+
     // if this traps (generates SIGFPE), verify (in the signal handler)
     // that integer arithmetic is expected to trap
-    result  = non_zero / zero;
-    result += non_zero % zero;
+    TRY {
+        result  = non_zero / zero;
+        result += non_zero % zero;
+    }
+    EXCEPT (1) {
+        trapped = true;
+    }
 
     // if we get this far, verify that integer arithmetic is known not
     // to trap
-    assert (!std::numeric_limits<int>::traps);
+    assert (trapped == std::numeric_limits<int>::traps);
 
     (void)&result;
 



RE: svn commit: r661873 - /stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp

Posted by Travis Vitek <Tr...@roguewave.com>.
 

>-----Original Message-----
>From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor
>Sent: Saturday, May 31, 2008 3:18 PM
>To: dev@stdcxx.apache.org
>Subject: Re: svn commit: r661873 - 
>/stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp
>
>vitek@apache.org wrote:
>> Author: vitek
>> Date: Fri May 30 14:24:06 2008
>> New Revision: 661873
>> 
>> URL: http://svn.apache.org/viewvc?rev=661873&view=rev
>> Log:
>> 2008-05-30  Travis Vitek  <vi...@roguewave.com>
>> 
>> 	STDCXX-833
>> 	* tests/regress/18.limits.traps.stdcxx-624.cpp: Add special
>> 	handling for divide by zero on windows.
>> 
>[...]
>> @@ -66,14 +76,21 @@
>>      if (std::numeric_limits<int>::traps)
>>          std::signal (SIGFPE, handle_FPE);
>>  
>> +    bool trapped = false;
>> +
>>      // if this traps (generates SIGFPE), verify (in the 
>signal handler)
>>      // that integer arithmetic is expected to trap
>> -    result  = non_zero / zero;
>> -    result += non_zero % zero;
>> +    TRY {
>> +        result  = non_zero / zero;
>> +        result += non_zero % zero;
>> +    }
>> +    EXCEPT (1) {
>> +        trapped = true;
>> +    }
>>  
>>      // if we get this far, verify that integer arithmetic 
>is known not
>>      // to trap
>
>Since after this change it's no longer true that the assertions below
>verify that integer arithmetic does not trap the comment above needs
>to be updated. (The comment about SIGFPE above could also stand to
>be updated to explain that the handler is never entered on Windows.
>

Committed in r662468
[http://svn.apache.org/viewvc?view=rev&revision=662468]

Travis

>Martin
>
>> -    assert (!std::numeric_limits<int>::traps);
>> +    assert (trapped == std::numeric_limits<int>::traps);
>>  
>>      (void)&result;
>>  
>> 
>> 
>
>

Re: svn commit: r661873 - /stdcxx/branches/4.2.x/tests/regress/18.limits.traps.stdcxx-624.cpp

Posted by Martin Sebor <se...@roguewave.com>.
vitek@apache.org wrote:
> Author: vitek
> Date: Fri May 30 14:24:06 2008
> New Revision: 661873
> 
> URL: http://svn.apache.org/viewvc?rev=661873&view=rev
> Log:
> 2008-05-30  Travis Vitek  <vi...@roguewave.com>
> 
> 	STDCXX-833
> 	* tests/regress/18.limits.traps.stdcxx-624.cpp: Add special
> 	handling for divide by zero on windows.
> 
[...]
> @@ -66,14 +76,21 @@
>      if (std::numeric_limits<int>::traps)
>          std::signal (SIGFPE, handle_FPE);
>  
> +    bool trapped = false;
> +
>      // if this traps (generates SIGFPE), verify (in the signal handler)
>      // that integer arithmetic is expected to trap
> -    result  = non_zero / zero;
> -    result += non_zero % zero;
> +    TRY {
> +        result  = non_zero / zero;
> +        result += non_zero % zero;
> +    }
> +    EXCEPT (1) {
> +        trapped = true;
> +    }
>  
>      // if we get this far, verify that integer arithmetic is known not
>      // to trap

Since after this change it's no longer true that the assertions below
verify that integer arithmetic does not trap the comment above needs
to be updated. (The comment about SIGFPE above could also stand to
be updated to explain that the handler is never entered on Windows.

Martin

> -    assert (!std::numeric_limits<int>::traps);
> +    assert (trapped == std::numeric_limits<int>::traps);
>  
>      (void)&result;
>  
> 
>