Re: dead code identification

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

 



On 2/13/08 11:58 AM, Mark Hampton wrote:

Could you explain the difference please.

Sure.

Unreachable code:


foo (int i)
{
   if (1)
     return i + 3;

   return i - 2;	<-- Unreachable code
}

Dead code:

foo (int i)
{
  int x;

  x = i + 1;		<-- Dead code
  x = 4;
  return x * 2;
}

They are similar in that neither has any effect on program output.

They are different in that unreachable code means that no control flow path reaches it, whereas dead code is on live control flow paths but its execution does not affect program output.


Diego.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux