This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't pedwarn about static const variables in inline functions (PR c/35017)


Jakub Jelinek writes: 
> ISO C99 6.7.4p3 says:
> "An inline definition of a function with external linkage shall not contain a
> definition of a modifiable object with static storage duration, and shall not
> contain a reference to an identifier with internal linkage."
> but gcc (4.3 regression) warns even about definitions of non-modifiable objects
> with static storage duration and about references to identifiers with no
> linkage (static vars in the current function).

Can you also take a look at PR34000?  It's not quite the same issue, but
this warning also triggers when an extern inline function calls a static
inline function.

This is a bit harder to argue from the C99 definition (is a static inline
function "an identifier with internal linkage"?) but in practice it's
problematic, so the warning should in this case be at most -pedantic only.

Here's an example on X86/SSE2 (i686-pc-linux-gnu, openSUSE 10.3):

#include <emmintrin.h>

extern inline __m128i vect_add(__m128i a, __m128i b)
{
        return _mm_add_epi8(a, b);
}

$ ~/GCC/bin/gcc -msse2 -c inline-test-sse.c
inline-test-sse.c: In function 'vect_add':
inline-test-sse.c:5: warning: '_mm_add_epi8' is static but used in inline function 'vect_add' which is not static

-- 
Jonathan Lennox
lennox at cs dot columbia dot edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]