Bug 12180 - [3.3/3.4 regression] Inline optimization fails for variadic function
Summary: [3.3/3.4 regression] Inline optimization fails for variadic function
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
Keywords: rejects-valid
Depends on:
Reported: 2003-09-05 10:36 UTC by Martin Husemann
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2003-09-08 06:16:24


Note You need to log in before you can comment on or make changes to this bug.
Description Martin Husemann 2003-09-05 10:36:16 UTC
I noticed this when trying to build mpg123 on NetBSD/sparc64. Matthew Green and
I reduced it to a small example code:

Store this in test.c:
typedef char * va_list;

void generic_sendmsg (char *fmt, ...)
        va_list ap;

        (void)(__builtin_next_arg(fmt), (ap) = (va_list)__builtin_saveregs());

void generic_sendstat()
        double t;

        generic_sendmsg("F %3.2f", t);

Then try:

$ cc -c -O3 test.c
test.c: In function `generic_sendstat':
test.c:7: error: `va_start' used in function with fixed args

$ cc -c -O3 -fno-inline test.c

The problem does not happen for non-sparc targets (AFAICT)
Comment 1 Andrew Pinski 2003-09-07 02:40:18 UTC
Is this a regression?
Comment 2 Andrey Petrov 2003-09-07 20:45:03 UTC
gcc 3.2.3 as
Reading specs from /work/gcc323/lib/gcc-lib/sparc64--netbsd/3.2.3/specs
Configured with: ../gcc/configure --prefix=/work/gcc323
--enable-languages=c,c++,objc --enable-nls=no --disable-shared sparc64--netbsd
Thread model: single
gcc version 3.2.3

also gives the same result
$ /work/gcc323/bin/gcc -c -O3 vatest.c
vatest.c: In function `generic_sendstat':
vatest.c:7: `va_start' used in function with fixed args
Comment 3 Eric Botcazou 2003-09-08 06:16:23 UTC
Confirmed on i586-redhat-linux-gnu as of 3.3.2 20030904 (prerelease) with:

void generic_sendmsg (char *fmt, ...)

void generic_sendstat()
  double t;

  generic_sendmsg("F %3.2f", t);

% gcc-3.3.2 -O3 pr12180.c
pr12180.c: In function `generic_sendstat':
pr12180.c:5: error: `va_start' used in function with fixed args

This is a regression from GCC 3.0.4.
Comment 4 CVS Commits 2003-10-03 00:23:32 UTC
Subject: Bug 12180

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-10-03 00:23:30

Modified files:
	gcc            : ChangeLog tree-inline.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: 20031002-1.c 

Log message:
	PR optimization/12180
	* tree-inline.c (inline_forbidden_p_1): Do not permit inlining of
	functions containing calls to
	PR optimization/12180
	* gcc.dg/20031002-1.c: New test.


Comment 6 Andrew Pinski 2003-10-03 01:13:22 UTC
Fixed in 3.3.2 and the mainline.