This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to warn about inlines which fail to return a value
On 05-Feb-2002, Jason Merrill <jason@redhat.com> wrote:
> >>>>> "Fergus" == Fergus Henderson <fjh@cs.mu.oz.au> writes:
>
> > Won't this patch result in spurious warnings in cases such as
> > int foo() {
> > // deliberate infinite loop
> > // (perhaps exited via exception or longjmp)
> > for (;;) {
> > bar();
> > }
> > }
>
> > ?
>
> I suppose so, but how common is code like that, really?
True, but off-hand I don't see any good, simple way of supressing
the warning in such cases.
> Besides, adding a
> return statement is a simple, harmless workaround.
Adding a return statement at the end of the function will result in a
warning about unreachable code (from some compilers), won't it?. If so,
it's not a harmless workaround -- it exchanges one warning for another.
Overall I think the patch is worthwhile, but it would be nice if there
was a better work-around for situations like that one.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.