__attribute__((noreturn)) may do other things besides suppress the "no
return from non-void function" warning. The gcc manual gives two
additional reasons for it:
void fatal () __attribute__ ((noreturn));
The `noreturn' keyword tells the compiler to assume that `fatal'
cannot return. It can then optimize without regard to what would
happen if `fatal' ever did return. This makes slightly better
code. More importantly, it helps avoid spurious warnings of
uninitialized variables.
Thus it is not a workaround, it is a way to give the optimizer extra
information. Standard C cannot express this assertion, to my
knowledge, so if you stick with ISO you get suboptimal code.
would be misleading -- it will never be executed and we know it. Using
__attribute__((noreturn)) reflects reality, which is usually a good
thing for coding style. (Whoops, I said "coding style".(: )
> Same happens with 'return' and 'break'. You type the same to add a
> '/* DO NOT REMEMBER THE PRECISE COMMENT */' to shut up the compiler
> instead of just writing
> case X:
> ...
> return xxx;
> break;
>
> ???
> Size optimization for the couple of bytes of the jump in return or break ?
Sorry, I don't follow your point here..
Peter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/