This is the mail archive of the gcc-bugs@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]

c/10488: Implementation of extern inline is exactly backwards


>Number:         10488
>Category:       c
>Synopsis:       Implementation of extern inline is exactly backwards
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 25 00:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     David Moore
>Release:        gcc 3.2 20020903
>Organization:
>Environment:
Red Hat Linux 8.0 3.2.7
>Description:
When extern inline is used on a function definition, a body for that function must be layed down in the current compilation unit binary. When just inline is given, no body should be layed down.

See the C99 standard ISO/EEC 9899:1999.

6.7.4 says that if all the declarations of a function are "inline" (not "extern inline") the compilation unit does not provide an external definition for the function. That is, the body is not layed down. Otherwise, if the extern storage class specifier is used, a body must be layed down as per section 6.9.

However, gcc 3.2 lays down a body when extern is not given and fails to do so when extern is used - exactly the opposite of what is required.

Example code:
===========================
#include <stdio.h>
EXTERNAL inline lay_me_down_maybe(int i) {return i*i+2;}
int main () {return lay_me_down_maybe(42);}

gcc -c -O2 -DEXTERNAL=extern example.c
nm example.o
00000000 T main

gcc -c -O2 -DEXTERNAL= example.c
nm example.o
00000010 T lay_me_down_maybe
00000000 T main




>How-To-Repeat:

>Fix:
Fix is probably simply a matter of flipping a condition but beware that there are uses of this in the gnu C header files where the usage is believed to also be backwards.
>Release-Note:
>Audit-Trail:
>Unformatted:


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