Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 31389
Product:  
Component:  
Status: RESOLVED
Resolution: INVALID
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Martin Michlmayr <tbm@cyrius.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 31389 depends on: Show dependency tree
Show dependency graph
Bug 31389 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2007-03-29 11:50
Is the following buggy core or a bug in 4.3?  I don't see why it should fail.
The problem is that when I compile an inline function with -std=gnu99, it will
not be found during linking.

Example:

gcc -c t.c
gcc -c -std=gnu99 timer.c
gcc -o t t.o timer.o

This results in:

t.c:(.text+0x1c): undefined reference to `timerdiv'

but it works when I either remove the "inline" attribute to timerdiv or
the -std=gnu99.

Code:

timer.c:
#include <sys/time.h>

inline void
timerdiv(struct timeval *tvp, float div)
{
    double interval;

    if (div == 0 || div == 1)
        return;

    interval = ((double)tvp->tv_sec * 1000000 + tvp->tv_usec) / (double)div;
    tvp->tv_sec = interval / (int)1000000;
    tvp->tv_usec = interval - (tvp->tv_sec * 1000000);
}



t.c:

#include <sys/time.h>

struct tcpr_speed_s {
    float speed;
};
typedef struct tcpr_speed_s tcpr_speed_t;

struct tcpreplay_opt_s {
       tcpr_speed_t speed;
};
typedef struct tcpreplay_opt_s tcpreplay_opt_t;

struct timeval nap;
tcpreplay_opt_t options;
extern void timerdiv(struct timeval *tvp, float div);

int main() {
        timerdiv(&nap, options.speed.speed);
        return 0;
}

------- Comment #1 From Martin Michlmayr 2007-03-29 11:51 -------
I forgot to mention that it works fine with 4.1.

------- Comment #2 From Richard Guenther 2007-03-29 14:24 -------
Inline behavior is now C99 compatible by default, you need to use extern inline
in this case.

------- Comment #3 From Andrew Pinski 2007-03-29 15:15 -------
Plain inline without any thing which says static or extern in C99 is the same
as what GNU-C90 considers as their "extern inline" and not what C99 considers
as "extern inline".  If you add a prototype that says extern, it will just
work.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug