http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47457
Summary: g++ calls without optimisation incorrectly from
explicitly optimised code
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 23116
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23116
preprocessed source
When build this code without optimisation, like that,
g++ -o optimizetest optimizetest.cpp
looks like function call from optimised function passes wrong parameters to
static inline function
#include <stdio.h>
static inline void bar(int a)
{
printf("%d\n", a);
}
void foo() __attribute__((optimize("O2")));
void foo()
{
int a = 10;
bar(a);
}
int main(int, char**)
{
foo();
return 0;
}
If compile with more than 0 optimisation level this works fine and prints 10,
otherwise when compile without optimisation this produces garbage instead of
10.