This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/10180: gcc fails to warn about non-inlined function


>Number:         10180
>Category:       c++
>Synopsis:       gcc fails to warn about non-inlined function
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 21 11:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     wwieser at gmx dot de
>Release:        3.2 (release), 3.2.3 (prerelease) and others
>Organization:
>Environment:
Linux ix86
>Description:
Try compiling the following code: 
--------<test.cpp>--------
static inline int foo(int x);

int main()
{
        return(foo(17));
}

inline int foo(int x)
        {  return(x);  }
--------------------------

Compiling it with gcc-2.95 gives:
bash# gcc -s -O2 -Winline test.cc
test.cc: In function `int main()':
test.cc:1: warning: can't inline call to `int foo(int)'
test.cc:5: warning: called from here
...which is what you would expect. 

Compiling it with gcc-3.2 results in: 
bash# gcc -Winline -S -O2 test.cc
bash# 
...nothing. 

However, looking at the assembler code:
--------<test.s>---------
...
main:
       pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        movl    $17, (%esp)
        call    _Z3fooi       <-------
        movl    %ebp, %esp
        popl    %ebp
        ret
...
---------------------
reveales that the function foo() actually was NOT inlined. 

I thought, gcc-3 was finally clever enough to perform inlining 
of functions which are declared inline before but defined after 
a calling location. If it cannot, it should at least issue the 
requested warning. 
>How-To-Repeat:
See above. 
>Fix:
Ugh... If I had any clue about gcc code...
At least gcc-2.95 still warns correctly :)
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]