https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84229
Bug ID: 84229
Summary: A valid code rejected with -flto
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: hubicka at ucw dot cz, jamborm at gcc dot gnu.org,
marxin at gcc dot gnu.org
Target Milestone: ---
I've just reduced following test-case:
$ cat aa.i
void a ();
extern __inline int
open (char b, int c)
{
if (__builtin_constant_p (c) && __builtin_va_arg_pack_len ())
a ();
}
$ cat bb.i
void open ();
void
_md_OpenAnonFileMap_genName ()
{
open (_md_OpenAnonFileMap_genName, 0);
}
With:
$ gcc -O3 -flto=9 -fPIC -shared aa.i bb.i --param ipa-cp-eval-threshold=100
-std=gnu11
aa.i: In function ‘open.constprop’:
aa.i:5:35: error: invalid use of ‘__builtin_va_arg_pack_len ()’
if (__builtin_constant_p (c) && __builtin_va_arg_pack_len ())
^
make: *** [/tmp/cc1JFDZe.mk:2: /tmp/ccK61RIy.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
It fails for all releases starting from 4.7.0.
Using -O2 or non-LTO mode works fine.