0

while doing an memory checkup with purifier, it is showing an IPR error on the following statement.

 throw true;

What could be the issue?

void Myfunc(char *p_trace_id,char *p_session_id,int &p_roam_flag)
{
   try
   {
      int set_id=0;

      if(0 == set_id)
         throw true;
   }

   catch(bool p_return_value)
   {
      if(!p_return_value)
      {
         g_Log.log(DEBUG, p_trace_id ,"[%s] %s<Line: %d> ", p_session_id ,__FUNCTION__,__LINE__);

         p_roam_flag = 0;
      }
   }
   catch(...)
   {
      g_Log.log(DEBUG, p_trace_id ,"[%s] %s<Line: %d> ", p_session_id ,__FUNCTION__,__LINE__);
   }
}

As per my analysis, there is issue in older version of purify. But i am using latest version.

Purify V7.0
Solaris V5.0
VINOTH ENERGETIC
  • 1,775
  • 4
  • 23
  • 38
  • That code is syntactically incorrect. Did your copy-and-paste key malfunction? – molbdnilo Feb 11 '16 at 10:26
  • @molbdnilo Yes! Corrected – VINOTH ENERGETIC Feb 11 '16 at 10:32
  • 3
    The rule 'don't use exceptions for flow control' is much over-cited, way beyond its original purpose (and yes I was there when it started), and there are few live examples of why you should not do so within a method, but this is certainly one of them. There is no reason to use `throw true` here at all, and no reason why the entire `catch (bool ...)` block can't be immediately after the `if` statement. Don't write code like this.. – user207421 Feb 11 '16 at 10:36
  • @EJP I will try to follow this, but i felt like returning the code at beginning of the function after checking pre-condition as something odd. – VINOTH ENERGETIC Feb 11 '16 at 11:33
  • How are you compiling the code? 64- or 32-bit? – Andrew Henle Feb 11 '16 at 21:40
  • @VinothKumar Try a 32-bit compile and see if you still get the error. See http://www-01.ibm.com/support/docview.wss?uid=swg1PQ92064 – Andrew Henle Feb 12 '16 at 09:48
  • @AndrewHenle But i ran the sample program with try and catch and compiled as 64 bit. But i am not getting any error in purifier. – VINOTH ENERGETIC Feb 12 '16 at 10:01
  • Is the sample program the same as the program you posted in your question? – Andrew Henle Feb 12 '16 at 13:42
  • @AndrewHenle No. But i wrote the same similar code like this.. Do you want to attach the sample code. – VINOTH ENERGETIC Feb 15 '16 at 05:39
  • Does the sample code `throw` a `bool`? If not, it won't really help. I still think you're running into something like the bug I posted a few days ago, and that's why I wanted you to try both a 32-bit and 64-bit compile with the code that's giving you the error. You can most likely get a 32-bit compile by adding `-m32` to your compile options. – Andrew Henle Feb 15 '16 at 18:58

0 Answers0