Discussion:
[Bug c/55965] New: gcc -std=c99 emits code for inline even without extern
jeremyhu at macports dot org
2013-01-14 04:44:06 UTC
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965



Bug #: 55965

Summary: gcc -std=c99 emits code for inline even without extern

Classification: Unclassified

Product: gcc

Version: unknown

Status: UNCONFIRMED

Severity: normal

Priority: P3

Component: c

AssignedTo: ***@gcc.gnu.org

ReportedBy: ***@macports.org





$ cat /tmp/testa.c

inline int isalnum(int _c) { return 1; }

inline int _isalnum(int _c) { return 1; }



$ /opt/local/bin/gcc-mp-4.8 -c /tmp/testa.c -o /tmp/test.o -std=c99



$ nm /tmp/test.o

0000000000000010 s EH_frame1

0000000000000000 T _isalnum



---



isalnum is being emitted with external linkage even though it is inline and

never declared as 'extern inline' It looks like gcc may have implicit extern

declarations for some functions which is forcing this 'inline' definition to be

treated asn an 'extern inline' definition.
mpolacek at gcc dot gnu.org
2014-10-23 14:36:07 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-10-23
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yes, I think this is a bug. But I suppose that nm output mentioned isalnum,
not _isalnum.
manu at gcc dot gnu.org
2014-10-23 16:36:21 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Yes, I get:

***@gcc10:~$ nm test.o
0000000000000000 T isalnum

and with:

~/test1/216257/build/gcc/xgcc -B ~/test1/216257/build/gcc/ -std=c99 test.c -c
-o test.o -fno-builtin-isalnum

I get nothing. Thus the analysis seems right but not sure how to fix it.
jeremyhu at macports dot org
2014-10-24 02:32:49 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965

--- Comment #3 from Jeremy Huddleston Sequoia <jeremyhu at macports dot org> ---
On OSX, the _isalnum symbol corresponds to the isalnum() function and the
__isalnum symbol would correspond to the _isalnum() function. It is emitting
the _isalnum symbol (for isalnum()) but not the __isalnum symbol (because
_isalnum() is being inlined).

I suspect you seeing an isalnum symbol is because you're on a different
platform that does not _-prefix.
jakub at gcc dot gnu.org
2014-10-24 07:14:06 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The implicit builtin FUNCTION_DECL should have UNKNOWN_LOCATION or
BUILTIN_LOCATION, so should be easy to differentiate from explicit user extern
decl. Just it is important that when an inline without extern is merged with
the implicit decl that the result doesn't look like user extern inline
or user extern decl followed by inline decl.

Loading...