Bug 736451 - gcc drops inline function incorrectly with "-std=c99"
Summary: gcc drops inline function incorrectly with "-std=c99"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-07 17:37 UTC by Kirby Zhou
Modified: 2011-09-07 18:04 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-07 18:04:33 UTC


Attachments (Terms of Use)

Description Kirby Zhou 2011-09-07 17:37:52 UTC
Description of problem:

A simple C program can not be compiled by gcc with "-std=c99"

Version-Release number of selected component (if applicable):

gcc-4.4.5-6.el6.x86_64
gcc-4.6.0-10.fc15.x86_64

How reproducible:

100%


Steps to Reproduce:

[root@djt-17-109-v06 tmp]# cat c99bug.c 
#include <stdio.h>

struct dummy;

inline int 
__foo(struct dummy *disk)
{
        printf("dummy\n");
        return -1;
}

static struct dummy *
foo_wrapper(const char *device)
{
        struct dummy* disk = (struct dummy*)device;
        __foo(disk);
        return NULL;
}

int
main(int argc, char *argv[])
{
        foo_wrapper("");
        return 0;
}

[root@djt-17-109-v06 tmp]# gcc -std=c99 c99bug.c 
/tmp/ccGNGqb6.o: In function `foo_wrapper':
c99bug.c:(.text+0x1c): undefined reference to `__foo'
collect2: ld returned 1 exit status

 
Actual results:


Expected results:

compile the simple demo code successfully.

Additional info:

The following gcc do not have this bug.

gcc-4.1.2-51.el5
gcc44-4.4.4-13.el5

Comment 2 Jakub Jelinek 2011-09-07 18:04:33 UTC
That is not a bug, it is what ISO C99 requires.  It is incompatible with the GNU inline extension behavior, and starting with GCC 4.3 -std=c99 or -std=gnu99 enables the ISO C99 mandated semantics.  You can use -fgnu89-inline command line option to force the GNU inline semantics, or you can use __attribute__((gnu_inline)) on functions that should have the GNU inline semantics.


Note You need to log in before you can comment on or make changes to this bug.