lkml.org 
[lkml]   [2008]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] MIPS: Make BUG() __noreturn.
On Fri, 21 Nov 2008, Geert Uytterhoeven wrote:

> > That sounds like your __noreturn macro is wrong.
> >
> > Try using __attribute__ ((__noreturn__))
> >
> > if that works then fix up the __noreturn definitions for the MIPS and gcc
> > you have.
>
> Nope, gcc is too smart:
>
> $ cat a.c
>
> int f(void) __attribute__((__noreturn__));
>
> int f(void)
> {
> }
>
> $ gcc -c -Wall a.c
> a.c: In function f:
> a.c:6: warning: `noreturn' function does return
> $

Hmm, in the case of your example the warning is justified, because the
(virtual) "return" statement of your function is in a unconditional block.
Otherwise it looks like the attribute is useless -- it looks like it can
only be used for functions where GCC can determine the function does not
return anyway. Which means it is redundant.

The cases where within the function concerned there is a volatile asm or
a conditional block which cannot be determined with simple static analysis
that it does stop look like legitimate ones for the use of the "noreturn"
attribute and my opinion is GCC should not warn about them with -Wall,
though a separate -W<whatever> option for the inquisitive would make sense
to me. It might be worthwhile to have a look into archives of the GCC
mailing lists to see how the implementation has evolved into the current
form and if no useful conclusion can be made, to bring the issue now
and/or file a bug report.

Maciej


\
 
 \ /
  Last update: 2008-11-21 12:17    [W:0.062 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site