Add assertion to detect TimeUnit<N> divide by zero (if not detected, it creates an infinite loop)
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu, 17 Apr 2008 17:19:24 +0100
changeset 2921 8a616a8b723a
parent 2920 67a8290b9336
child 2923 dbbe74916235
child 2972 d76553495b91
child 2987 4fe951be604c
Add assertion to detect TimeUnit<N> divide by zero (if not detected, it creates an infinite loop)
src/simulator/nstime.h
--- a/src/simulator/nstime.h	Wed Apr 16 10:52:38 2008 -0700
+++ b/src/simulator/nstime.h	Thu Apr 17 17:19:24 2008 +0100
@@ -274,6 +274,7 @@
 template <int N1, int N2>
 TimeUnit<N1-N2> operator / (TimeUnit<N1> const &lhs, TimeUnit<N2> const &rhs)
 {
+  NS_ASSERT (rhs.GetHighPrecision ().GetDouble () != 0);
   HighPrecision retval = lhs.GetHighPrecision ();
   retval.Div (rhs.GetHighPrecision ());
   return TimeUnit<N1-N2> (retval);