Document Number: WG14 N824/X3J11 98-023
WG14/N824 C9X Public Comment WG14/N824
Sponsoring National Body: J11 Date: 98/05/15
Author: Tom MacDonald
Author Affiliation: Silicon Graphics Inc.
Postal Address: 655F Lone Oak Drive, Eagan, MN 55409 USA
E-mail Address: email@example.com
Telephone Number: +1 612 6835818
Fax Number: +1 612 6835307
Number of individual comments: 2
%% Improved Words for Function Inlining %%
declaration-specifiers init-declarator-list-opt ;
6.5.4 Function specifiers
[#2] Function specifiers shall be used only in the
declaration of an identifier for a function.
[#3] An inline definition (see below) of a function with
external linkage shall not contain a definition of an object
with static storage duration that can be modified, and shall
not contain a reference to an identifier with internal
[#4] The inline function specifier shall not appear in a
declaration of main.
[#5] A function declared with an inline function specifier
is an inline function. Making a function an inline function
suggests that calls to the function be as fast as possible
by using, for example, an alternative to the usual function
call mechanism known as ``inline substitution''.101 The
extent to which such suggestions are effective is
[#6] Any function with internal linkage can be an inline
function. For a function with external linkage, the
following restrictions apply. If a function is declared
with an inline function specifier, then it shall also be
defined in the same translation unit. If all of the file
scope declarations for a function in a translation unit
include the inline function specifier without extern, then
the definition in that translation unit is an inline
definition. An inline definition does not provide an
external definition for the function, and does not forbid an
external definition in another translation unit. An inline
definition provides an alternative to an external
definition, which a translator may use to implement any call
to the function in the same translation unit. It is
unspecified whether a call to the function uses the inline
definition or the external definition.
** add a footnote here
101. Inline substitution is not textual substitution, nor
does it create a new function. Therefore, for example,
the expansion of a macro used within the body of the
** Since an inline definition of a function is distinct from
the corresponding external definition, and any other
corresponding inline definition in another translation unit,
all corresponding objects with static storage duration are
also distinct in each of these definitions.
The ** footnote clarifies a point made by Hugh Redelmeier in an Email he
sent last March. The intent of the current proposal is that an "inline
definition of function with external linkage" is distinct from the
"external definition of the function". The implementation is at liberty
to choose which one it wants to call, but it's calling a different
definition of the function. Thus, an static objects inside the function
(that cannot be be modified) are distinct, and do not share the same
memory as the corresponding static object in either the external definition
or a different inline function in another TU.
From: "D. Hugh Redelmeier" <firstname.lastname@example.org>
Date: Fri, 27 Mar 1998 13:55:51 -0500
To: Thomas MacDonald <email@example.com>
cc: Standard C <SC22WG14@dkuug.dk>
Subject: Re: (SC22WG14.5346) static objects in inline functions
I now see how this is supposed to work, but I don't think that the
words achieve this.
| The Draft says the following about string literals:
| These arrays need not be distinct provided their
| elements have the appropriate values.
I guess that the required words are sort of the opposite:
implementations are allowed to collapse distinct instances of strings,
but are allowed to create multiple instances of the same static in an
I suggest words something like:
Each invocation of an inline function may or may not have distinct
instances of its static objects.
Without these words or something like them, I don't see that the standard
allows an implementation to instantiate these statics multiple times. By
"its static objects" I meant function statics and string literals -- does
this need to be spelled out?