[ace-users] Division by zero in ACE_Stats::quotient() method

Vural, Okan okan.vural at siemens.com
Thu Oct 1 02:00:02 CDT 2015


Hello All,

In the both "ACE_Stats::quotient" methods there seems a potential division by zero problem (See below). It is independent of platform, this is why I didn't send the problem in a Problem Report. And I checked the latest version in ACE SVN as well. It seems still same in the latest version.

ACE Version     : V 630
File            : Stats.cpp
Method  :

void
ACE_Stats::quotient (const ACE_UINT64 dividend,
                     const ACE_UINT32 divisor,
                     ACE_Stats_Value &quotient)
{
  // The whole part of the division comes from simple integer division.
  quotient.whole (static_cast<ACE_UINT32> (divisor == 0
                                           ?  0  :  dividend / divisor));

  if (quotient.precision () > 0  ||  divisor == 0)
    {
      const ACE_UINT32 field = quotient.fractional_field ();
...
      quotient.fractional (static_cast<ACE_UINT32> (
                             dividend % divisor * field / divisor));

With best regards,
Okan Vural

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/ace-users/attachments/20151001/8e109ed2/attachment.html>


More information about the ace-users mailing list