Re: Code optimization: warning for code that hangs

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

 



On Sat, Jun 23, 2012 at 5:30 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> "Peter A. Felvegi" <petschy@xxxxxxxxxxxxxxxxxx> writes:
>
>> My question is: wouldn't it be possible to print a warning when a jmp
>> to itself or trivial infinite recursion is generated? The code
>> compiled fine w/ -Wall -Wextra -Werror w/ 4.6 and 4.7.
>
> This question is not appropriate for the mailing list gcc@xxxxxxxxxxx,
> which is for discussions about the development of GCC.  It would be
> appropriate for gcc-help@xxxxxxxxxxx.  Please take any followups to
> gcc-help.  Thanks.
>
> I'm not yet convinced that a -Wall warning would be worth the effort in
> this case.  You have basically come up with a complicated way to write
>
> void f() { f(); }
>
> I suppose I think it would be reasonable to issue a -Wall warning for
> code like that.  The trick is detecting it.  Obviously there is nothing
> wrong with a recursive call.  What is different here is that the
> recursive call is unconditional.  I don't see a way to detect that
> without writing a specific warning pass to look for that case.  And I
> think this case is rare enough, and easy enough to discover in other
> ways, that I don't think a warning would be worth the cost in
> compilation time and compiler maintenance.
>
> If the problem can be detected cheaply in the course of an existing
> pass, I would support a warning.

I suppose you could rely on detecting the CFG form of an uncontional
goto to an empty block from that block - the above recursion should
have been eliminated by the tail-recursion pass.

The issue with this kind of warnings is always that they are issued
even when the endless loop might not be reached at runtime.

Richard.

> Ian



[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