public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A bug (?) with inline functions at O0: undefined reference
@ 2015-03-06 16:13 Ilya Verbin
  2015-03-06 16:21 ` Marek Polacek
  2015-03-06 16:21 ` Marc Glisse
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Verbin @ 2015-03-06 16:13 UTC (permalink / raw)
  To: gcc

Hi All,

I've discovered a strange behaviour on trunk gcc, here is the reproducer:

inline int foo ()
{
  return 0;
}

int main ()
{
  return foo ();
}

$ gcc main.c
/tmp/ccD1LeXo.o: In function `main':
main.c:(.text+0xa): undefined reference to `foo'
collect2: error: ld returned 1 exit status

Is this a bug?  If yes, is it known?
GCC 4.8.3 works fine though.

Thanks,
  -- Ilya

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

* Re: A bug (?) with inline functions at O0: undefined reference
  2015-03-06 16:13 A bug (?) with inline functions at O0: undefined reference Ilya Verbin
@ 2015-03-06 16:21 ` Marek Polacek
  2015-03-06 16:21 ` Marc Glisse
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Polacek @ 2015-03-06 16:21 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: gcc

On Fri, Mar 06, 2015 at 07:12:48PM +0300, Ilya Verbin wrote:
> Hi All,
> 
> I've discovered a strange behaviour on trunk gcc, here is the reproducer:
> 
> inline int foo ()
> {
>   return 0;
> }
> 
> int main ()
> {
>   return foo ();
> }
> 
> $ gcc main.c
> /tmp/ccD1LeXo.o: In function `main':
> main.c:(.text+0xa): undefined reference to `foo'
> collect2: error: ld returned 1 exit status
> 
> Is this a bug?  If yes, is it known?
> GCC 4.8.3 works fine though.

Not a bug, just different inline semantics now that the default is
gnu11.  See https://gcc.gnu.org/gcc-5/porting_to.html for more info.

	Marek

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

* Re: A bug (?) with inline functions at O0: undefined reference
  2015-03-06 16:13 A bug (?) with inline functions at O0: undefined reference Ilya Verbin
  2015-03-06 16:21 ` Marek Polacek
@ 2015-03-06 16:21 ` Marc Glisse
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Glisse @ 2015-03-06 16:21 UTC (permalink / raw)
  To: Ilya Verbin; +Cc: gcc

On Fri, 6 Mar 2015, Ilya Verbin wrote:

> I've discovered a strange behaviour on trunk gcc, here is the reproducer:
>
> inline int foo ()
> {
>  return 0;
> }
>
> int main ()
> {
>  return foo ();
> }
>
> $ gcc main.c
> /tmp/ccD1LeXo.o: In function `main':
> main.c:(.text+0xa): undefined reference to `foo'
> collect2: error: ld returned 1 exit status
>
> Is this a bug?  If yes, is it known?
> GCC 4.8.3 works fine though.

Not a bug, that's what inline means in C99 and later.

-- 
Marc Glisse

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

end of thread, other threads:[~2015-03-06 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 16:13 A bug (?) with inline functions at O0: undefined reference Ilya Verbin
2015-03-06 16:21 ` Marek Polacek
2015-03-06 16:21 ` Marc Glisse

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).