Package: gcc-4.3 Version: 4.3-20071020-1 Severity: normal Hi, gcc emits a warning that should not be there probably.
[EMAIL PROTECTED]:~/inline$ cat inline.c extern inline char func( int arg ) { static const char foomap[4] = {2, 4, 8, 16}; return foomap[arg & 3]; } [EMAIL PROTECTED]:~/inline$ gcc -c -Wall inline.c inline.c: In function 'func': inline.c:4: warning: 'foomap' is static but declared in inline function 'func' which is not static inline.c:6: warning: 'foomap' is static but used in inline function 'func' which is not static [EMAIL PROTECTED]:~/inline$ See fwd message bellow, please. | To: Vaclav Ovsik <[EMAIL PROTECTED]> | Cc: Bernd Zeimetz <[EMAIL PROTECTED]>, [EMAIL PROTECTED] | Subject: Re: RFS: ustr (updated package) | From: James Antill <[EMAIL PROTECTED]> | Date: Mon, 05 Nov 2007 20:18:24 -0500 | | Vaclav Ovsik <[EMAIL PROTECTED]> writes: | | > I have setup gcc-4.3 from experimental on a sid xen guest. | > The warning is emitted for example on following (simplified) code: | > | > extern inline char func( int arg ) | > { | > static const char foomap[4] = {2, 4, 8, 16}; | > | > return foomap[arg & 3]; | > } | | Yes, from the link Bernd provided the warning is emitted basically | for anything that uses the static keyword. The above is correct | though, IMO, as is: | | extern inline char func( int arg ) | { | static const char foomap[] = "abc"; | | return foomap[arg & 3]; | } | | > I have red several times the ISO paragraph :). It seems to me, that | > paragraph applies to this situation. | > IMHO foomap is `reference to an identifier with internal linkage'. | > Or no? :) | | From ISO 9899:1999 6.2.2 Linkages of identifiers: | | #1 | An identifier declared in different scopes or in the same scope more | than once can be made to refer to the same object or function by a | process called linkage. There are three kinds of linkage: external, | internal, and none. | | #2 | If the declaration of a file scope identifier for an object or a | function contains the storage-class specifier static, the identifier | has internal linkage. | [...] | #6 | The following identifiers have no linkage: an identifier declared to | be anything other than an object or a function; an identifier declared | to be a function parameter; a block scope identifier for an object | declared without the storage-class specifier extern. | | ...from that #2 doesn't apply because the identifier isn't at file | scope, and so the last part of #6 does apply. | | Also it's "well known" that in: | | void foobar(void) | { | const char *const foo = "abcd"; | static const char bar[] = "abcd"; | } | | ...foo and bar do the same thing, point to some constant data, but bar | is the better version. | As with foo you have a allocated two objects (the pointer being the | second object), and have to use/manage them both, but with bar you | have just "named" a single object. | | -- | James Antill -- [EMAIL PROTECTED] | C String APIs use too much memory? ustr: length, ref count, size and | read-only/fixed. Ave. 44% overhead over strdup(), for 0-20B strings | http://www.and.org/ustr/ Regards. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (990, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.18-5-xen-686 (SMP w/1 CPU core) Locale: LANG=C, LC_CTYPE=cs_CZ.ISO-8859-2 (charmap=ISO-8859-2) Shell: /bin/sh linked to /bin/bash Versions of packages gcc-4.3 depends on: ii binutils 2.18.1~cvs20071027-1 The GNU assembler, linker and bina ii cpp-4.3 4.3-20071020-1 The GNU C preprocessor ii gcc-4.3-base 4.3-20071020-1 The GNU Compiler Collection (base ii libc6 2.6.1-6 GNU C Library: Shared libraries ii libgcc1 1:4.3-20071020-1 GCC support library ii libgmp3c2 2:4.2.2+dfsg-1 Multiprecision arithmetic library ii libgomp1 4.3-20071020-1 GCC OpenMP (GOMP) support library ii libmpfr1ldbl 2.3.0.dfsg.1-2 multiple precision floating-point Versions of packages gcc-4.3 recommends: ii libc6-dev 2.6.1-6 GNU C Library: Development Librari -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]