c/1601: A static inline function as a parameter of another static inline function is not inlined.

jodaman@ee1.bradley.edu jodaman@ee1.bradley.edu
Tue Jan 9 20:26:00 GMT 2001


>Number:         1601
>Category:       c
>Synopsis:       A static inline function as a parameter of another static inline function is not inlined.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 09 20:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     John Dahlstrom
>Release:        gcc version 2.97 20010103 (experimental)
>Organization:
>Environment:
Tested with the online compiler at
http://www.codesourcery.com/gcc-compile.shtml
after initially noticing the problem with
gcc version 2.95.2 20000220 (Debian GNU/Linux)
>Description:
Calling a static inline function with a second static inline
function as a parameter does not inline the second function.
(The first function does inline correctly.)  Additionally,
the option "-Winline" does not warn that the second function
cannot be inlined, while the assembly output indicates that
the second function is not inlined.

The "C Extensions->Inline" info page for GCC does not
mention this limitation or a solution.  Although reverting
to a macro allows generation of the desired optimal output,
implementing non-trivial functions as macros is highly
undesirable.
>How-To-Repeat:
static inline int
f1( int (*f)(int y), int q )
{
  return( (*f)( q ) );
}

static inline int
f2( int z )
{
  return( z ^ 32 );
}

int fun( int x )
{
  return( f1( &f2, x ) );
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list