public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31389]  New: [4.3 Regression] undefined reference with inline function and -std=gnu99
@ 2007-03-29 10:51 tbm at cyrius dot com
  2007-03-29 10:51 ` [Bug c/31389] " tbm at cyrius dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tbm at cyrius dot com @ 2007-03-29 10:51 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/31389] [4.3 Regression] undefined reference with inline function and -std=gnu99
  2007-03-29 10:51 [Bug c/31389] New: [4.3 Regression] undefined reference with inline function and -std=gnu99 tbm at cyrius dot com
@ 2007-03-29 10:51 ` tbm at cyrius dot com
  2007-03-29 13:24 ` rguenth at gcc dot gnu dot org
  2007-03-29 14:15 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tbm at cyrius dot com @ 2007-03-29 10:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tbm at cyrius dot com  2007-03-29 11:51 -------
I forgot to mention that it works fine with 4.1.


-- 

tbm at cyrius dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tbm at cyrius dot com


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/31389] [4.3 Regression] undefined reference with inline function and -std=gnu99
  2007-03-29 10:51 [Bug c/31389] New: [4.3 Regression] undefined reference with inline function and -std=gnu99 tbm at cyrius dot com
  2007-03-29 10:51 ` [Bug c/31389] " tbm at cyrius dot com
@ 2007-03-29 13:24 ` rguenth at gcc dot gnu dot org
  2007-03-29 14:15 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-29 13:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-03-29 14:24 -------
Inline behavior is now C99 compatible by default, you need to use extern inline
in this case.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/31389] [4.3 Regression] undefined reference with inline function and -std=gnu99
  2007-03-29 10:51 [Bug c/31389] New: [4.3 Regression] undefined reference with inline function and -std=gnu99 tbm at cyrius dot com
  2007-03-29 10:51 ` [Bug c/31389] " tbm at cyrius dot com
  2007-03-29 13:24 ` rguenth at gcc dot gnu dot org
@ 2007-03-29 14:15 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-29 14:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  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.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-29 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-29 10:51 [Bug c/31389] New: [4.3 Regression] undefined reference with inline function and -std=gnu99 tbm at cyrius dot com
2007-03-29 10:51 ` [Bug c/31389] " tbm at cyrius dot com
2007-03-29 13:24 ` rguenth at gcc dot gnu dot org
2007-03-29 14:15 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).