GCC 3.4.3 (i686-pc-linux-gnu) generates incorrect code when a function
containing __builtin_return(__builtin_apply(...)) is inlined, whether by the
"inline" keyword or with -finline-functions.  For example, take this simple 
program:

int bar(int hoge) { return hoge; }
int foo(int xyzzy) {
__builtin_return(__builtin_apply(bar,__builtin_apply_args(),64)); }
int main(int ac, char **av) { return foo(9)==9 && foo(42)==42 ? 0 : 1; }

This should generate a main() with two calls to foo(), but with
-finline-functions, main() instead consists of a __builtin_apply() call to bar()
directly, using the arguments to main() rather than the argument passed to
foo().  See attached assembly listings.

$ gcc -vReading specs from /pkg/gcc/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: /tmp/packager17310.149/gcc-3.4.3/configure --prefix=/pkg/gcc
--enable-languages=c,c++ --disable-shared --disable-nls
Thread model: posix
gcc version 3.4.3

-- 
           Summary: __builtin_return(__builtin_apply()) inlined incorrectly
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcczilla at achurch dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to