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]

[Bug c++/16922] New: gcc inlines functions with attribute noinline


Well, so this tricked me in some function call time measurements:  
 
In the following code... 
 
----------<test.cc>----------------------------- 
int foo(int x) __attribute__((noinline)); 
int main() 
{ 
	for(int i=0; i<0x7fffffff; i++) 
		foo(i); 
} 
 
int foo(int x)  {  return(x);  } 
------------------------------------------------ 
 
...the function foo() actually gets inlined when compiled with  
 
  g++ -O2 -fno-rtti -fno-exceptions test.cc -o test.S 
 
as can be seen in the produced assembler code 
 
[...] 
main: 
	pushl	%ebp 
	xorl	%eax, %eax 
	movl	%esp, %ebp 
	subl	$8, %esp 
	andl	$-16, %esp 
	subl	$16, %esp 
	.p2align 4,,15 
.L6:                                 <-- loop start 
	incl	%eax 
	cmpl	$2147483647, %eax 
	jne	.L6                  <-- loop end 
[...] 
 
The "call foo" is missing and got optimized away.  
 
Version in question:  
  ggc (GCC) 3.4.2 20040808 (prerelease) 
 
Wolfgang

-- 
           Summary: gcc inlines functions with attribute noinline
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wwieser at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-linux-gnu
  GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16922


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