[Bug c/31389] New: [4.3 Regression] undefined reference with inline function and -std=gnu99

tbm at cyrius dot com gcc-bugzilla@gcc.gnu.org
Thu Mar 29 10:51:00 GMT 2007


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;
}


-- 
           Summary: [4.3 Regression] undefined reference with inline
                    function and -std=gnu99
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tbm at cyrius dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31389



More information about the Gcc-bugs mailing list