dead code identification
Mark Hampton
mark.hampton@certess.com
Wed Feb 13 16:45:00 GMT 2008
On Wednesday 13 February 2008 17:26, Matthew Woehlke wrote:
> Mark Hampton wrote:
> > I would like to identify dead/redundant code that is being optimized away
> > by gcc. Is there a way to have gcc report the line number associated with
> > this code ?
>
> I guess someone should point out that some commercial compilers (Sun's
> comes to mind) issue warnings for unreachable code. IMO this would make
> a nice improvement to gcc.
Thanks for that - I had not thought of using "unreachable code" as the search
term :
-Wunreachable-code
Warn if the compiler detects that code will never be executed.
So it does seem gcc supports this.
>
> As far as redundant code, though, redundant code can be more readable
> than the alternative (I've several times caught myself writing redundant
> code and hoping gcc would fold it in optimization).
I agree that redundant code can make things easier to read. I would like to be
able to identify which lines of code are redundant. Any hints most welcome.
Regards,
Mark
More information about the Gcc-help
mailing list