-flto with using the linker-plugin has an implicit -fwhole-program effect which brings foo local and allows IPA-SRA to remove the constant parameter. The testcase does not want this and breaks even without -flto if you make foo static.
Thus the following patch makes sure this doens't happen with -flto either. Tested on x86_64-unknown-linux-gnu, applied. Richard. 2011-03-16 Richard Guenther <rguent...@suse.de> PR testsuite/48147 * gcc.dg/guality/pr45882.c: Really make sure no inlining or cloning happens. Index: gcc/testsuite/gcc.dg/guality/pr45882.c =================================================================== --- gcc/testsuite/gcc.dg/guality/pr45882.c (revision 171045) +++ gcc/testsuite/gcc.dg/guality/pr45882.c (working copy) @@ -6,7 +6,7 @@ extern void abort (void); int a[1024]; volatile short int v; -__attribute__((noinline)) int +__attribute__((noinline,noclone,used)) int foo (int i, int j) { int b = i; /* { dg-final { gdb-test 16 "b" "7" } } */