lkml.org 
[lkml]   [2004]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: IA32 (2.6.2 - 2004-02-05.22.30) - 3 New warnings (gcc 3.2.2)
On Fri, Feb 06, 2004 at 06:22:08PM +0000, viro@parcelfarce.linux.theplanet.co.uk wrote:
>
> Umm... How about
>
> static inline void BUG() __attribute__((noreturn));
>
> static inline void BUG(void)
> {
> __asm__ ....
> }

Unfortunately gcc thinks that it knows better than you whether function
can return or not. I attempted to use noreturn attribute in couple of
my projects, but it is useless - unless you terminate your function
with for(;;) or with call to _exit(), it won't work.

vana:~# more m.c
static inline void BUG() __attribute__((noreturn));

static inline void BUG(void) {
__asm__ ("1: jmp 1b");
}

void main(void) {
BUG();
}

vana:~# gcc -W -Wall m.c
m.c:7: warning: return type of `main' is not `int'
m.c: In function `BUG':
m.c:3: warning: `noreturn' function does return
vana:~#

(gcc version 3.3.3 20040125 (prerelease) (Debian))

> > Better to just initialize the variable to a default value and avoid the
> > warning for now.
>
> Alternatively, we can just turn the damn thing into
> if (dev->mode == IMM_NIBBLE || dev->mode = IMM_PS2)
> ports = 3;
> else
> ports = 8;
> and be done with that...

Yes.
Petr Vandrovec

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:00    [W:0.055 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site