[Bug c/66222] New: gcc error: invalid use of '__builtin_va_arg_pack ()' at -O2 and up & pass at noopt

2015-05-20 Thread mshzhb at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66222

Bug ID: 66222
   Summary: gcc error: invalid use of '__builtin_va_arg_pack ()'
at -O2 and up & pass at noopt
   Product: gcc
   Version: 4.8.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mshzhb at gmail dot com
  Target Milestone: ---

Created attachment 35579
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35579&action=edit
source code

ABSTRACT: [gcc] error: invalid use of '__builtin_va_arg_pack ()' at -O2 and up
& pass at noopt

DRIVER PASS: 
DRIVER FAIL:gcc 4.8.2



OPTIONS PASS: noopt 
OPTIONS FAIL: -O2 -O3 and up

MACHINE DETAILS: (Optional: Specify machine name, OS and architecture)
lep8244bv   

detail:

Distributor ID: Ubuntu
Description:Ubuntu 14.04.2 LTS
Release:14.04
Codename:   trusty

Linux version 3.13.0-35-generic (buildd@fisher02) (gcc version 4.8.2 (Ubuntu
4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:57:29 UTC 2014

Architecture:  ppc64le
Byte Order:Little Endian
CPU(s):192
On-line CPU(s) list:  
0-3,8-11,16-19,24-27,32-35,40-43,48-51,56-59,64-67,72-75,80-83,88-91,96-99,104-107,112-115,120-123,128-131,136-139,144-147,152-155,160-163,168-171,176-179,184-187
Off-line CPU(s) list: 
4-7,12-15,20-23,28-31,36-39,44-47,52-55,60-63,68-71,76-79,84-87,92-95,100-103,108-111,116-119,124-127,132-135,140-143,148-151,156-159,164-167,172-175,180-183,188-191
Thread(s) per core:4
Core(s) per socket:6
Socket(s): 4
NUMA node(s):  4
Model: 8286-42A
L1d cache: 64K
L1i cache: 32K
L2 cache:  512K
L3 cache:  8192K
NUMA node0 CPU(s): 0-3,8-11,16-19,24-27,32-35,40-43
NUMA node1 CPU(s): 48-51,56-59,64-67,72-75,80-83,88-91
NUMA node16 CPU(s):96-99,104-107,112-115,120-123,128-131,136-139
NUMA node17 CPU(s):144-147,152-155,160-163,168-171,176-179,184-187

PROBLEM DESCRIPTION:
gcc error: invalid use of '__builtin_va_arg_pack ()' at -O2 and up but  pass at
noopt

error information :
In file included from /usr/include/stdio.h:937:0,
 from perlsdio.h:5,
 from iperlsys.h:203,
 from perl.h:325,
 from av.c:16:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h: In function 'sprintf':
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:33:3: error: invalid use of
'__builtin_va_arg_pack ()'
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
   ^
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h: In function 'snprintf':
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:64:3: error: invalid use of
'__builtin_va_arg_pack ()'
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
   ^
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h: In function 'fprintf':
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:97:3: error: invalid use of
'__builtin_va_arg_pack ()'
   return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
   ^
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h: In function 'printf':
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:104:3: error: invalid use of
'__builtin_va_arg_pack ()'
   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
   ^
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h: In function 'dprintf':
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:141:3: error: invalid use of
'__builtin_va_arg_pack ()'
   return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt,
   ^
-
STEPS TO REPRODUCE: (Reduce the code in the README.ksh file as much as
possible)
/usr/bin/gcc -m64 -D__64BIT__=1 -O3 -mcpu=power8  -fabi-version=4 -std=gnu99
-I_END_XOPTS -DSPEC_CPU2000 -DSPEC_CPU2000_LP64 -DSPEC_CPU2000_LINUX_PPC32
-DSPEC_CPU2000_NEED_BOOL -DHAS_FGETPOS -DHAS_FSETPOS   -fno-strict-aliasing -c
-o av.o av.c


-

TESTCASE SOURCE: (reduced where applicable): (this field is optional for SPEC
defects)
//av.c
see attachment


[Bug c/66222] gcc error: invalid use of '__builtin_va_arg_pack ()' at -O2 and up & pass at noopt

2015-05-20 Thread mshzhb at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66222

--- Comment #1 from Tong Liu  ---
//av.h

/*av.h
 *
 *Copyright (c) 1991-1999, Larry Wall
 *
 *You may distribute under the terms of either the GNU General Public
 *License or the Artistic License, as specified in the README file.
 *
 */

struct xpvav {
char*   xav_array;  /* pointer to first array element */
SSize_t xav_fill;   /* Index of last element present */
SSize_t xav_max;/* Number of elements for which array has space
*/
IV  xof_off;/* ptr is incremented by offset */
double  xnv_nv; /* numeric value, if any */
MAGIC*  xmg_magic;  /* magic for scalar array */
HV* xmg_stash;  /* class package */

SV**xav_alloc;  /* pointer to malloced string */
SV* xav_arylen;
U8  xav_flags;
};

#define AVf_REAL 1  /* free old entries */
#define AVf_REIFY 2 /* can become real */
#define AVf_REUSED 4/* got undeffed--don't turn old memory into SVs now */

#define Nullav Null(AV*)

#define AvARRAY(av) ((SV**)((XPVAV*)  SvANY(av))->xav_array)
#define AvALLOC(av) ((XPVAV*)  SvANY(av))->xav_alloc
#define AvMAX(av)   ((XPVAV*)  SvANY(av))->xav_max
#define AvFILLp(av) ((XPVAV*)  SvANY(av))->xav_fill
#define AvARYLEN(av)((XPVAV*)  SvANY(av))->xav_arylen
#define AvFLAGS(av) ((XPVAV*)  SvANY(av))->xav_flags

#define AvREAL(av)  (AvFLAGS(av) & AVf_REAL)
#define AvREAL_on(av)   (AvFLAGS(av) |= AVf_REAL)
#define AvREAL_off(av)  (AvFLAGS(av) &= ~AVf_REAL)
#define AvREIFY(av) (AvFLAGS(av) & AVf_REIFY)
#define AvREIFY_on(av)  (AvFLAGS(av) |= AVf_REIFY)
#define AvREIFY_off(av) (AvFLAGS(av) &= ~AVf_REIFY)
#define AvREUSED(av)(AvFLAGS(av) & AVf_REUSED)
#define AvREUSED_on(av) (AvFLAGS(av) |= AVf_REUSED)
#define AvREUSED_off(av) (AvFLAGS(av) &= ~AVf_REUSED)

#define AvREALISH(av)   (AvFLAGS(av) & (AVf_REAL|AVf_REIFY))

#define AvFILL(av)  ((SvRMAGICAL((SV *) (av))) \
  ? mg_size((SV *) av) : AvFILLp(av))