commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9296 - gnuradio/trunk/gnuradio-core/src/lib/general


From: eb
Subject: [Commit-gnuradio] r9296 - gnuradio/trunk/gnuradio-core/src/lib/general
Date: Thu, 14 Aug 2008 19:12:03 -0600 (MDT)

Author: eb
Date: 2008-08-14 19:12:02 -0600 (Thu, 14 Aug 2008)
New Revision: 9296

Modified:
   gnuradio/trunk/gnuradio-core/src/lib/general/gr_fxpt_nco.h
Log:
Trial fix for ticket:258 / integer overflow undefined / phase
accumulator.  Thanks to Stefan Bruens and Philip Ballister for working
on this.

According to the fine print in the C and C++ standards, if a signed
integer type overflows, the result is undefined.  As of gcc 4.3, gcc
was proving that our code was overflowing, and took advantage of the
"undefined" result to short circuit the evaluation.

Moral of the story:  if you're using a fixed point phase accumulator,
or anything else where you're counting on overflow happening, be sure
that your variable is unsigned.

See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37067 and
http://www.airs.com/blog/archives/120



Modified: gnuradio/trunk/gnuradio-core/src/lib/general/gr_fxpt_nco.h
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/general/gr_fxpt_nco.h  2008-08-14 
22:52:31 UTC (rev 9295)
+++ gnuradio/trunk/gnuradio-core/src/lib/general/gr_fxpt_nco.h  2008-08-15 
01:12:02 UTC (rev 9296)
@@ -30,7 +30,7 @@
  * \ingroup misc
  */
 class gr_fxpt_nco {
-  gr_int32     d_phase;
+  gr_uint32    d_phase;
   gr_int32     d_phase_inc;
 
 public:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]