https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78263

            Bug ID: 78263
           Summary: Compile failure with AltiVec library on PPC64le and
                    -std=c++11 flag
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: khill at us dot ibm.com
  Target Milestone: ---

Created attachment 39998
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39998&action=edit
Preprocessed source source for main.cpp

GCC is unable to compile C++ code which includes the AltiVec library with
-std=c++11 flag on PPC64le target.

The following code snippet will reproduce the error: 

#include <altivec.h>

int main(int argc, char *argv[])
{
  bool test = false;
  return 0;
}

GCC and AltiVec both define __bool causing the code to become invalid.

One solution found is to undef the following:

#undef vector 
#undef pixel 
#undef bool 

This solution is not always straightforward for larger code bases and requires
users of our tools to edit the source files of any project/example that
includes the AltiVec library (e.g CL/opencl.h).

Test Case on Ubuntu 16.04 w/ kernel 4.4.0-45-generic:

gcc -v -save-temps -std=c++11 -c main.cpp
Using built-in specs.
COLLECT_GCC=gcc
Target: powerpc64le-linux-gnu

...

Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.2) 

...

COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-c' '-mcpu=power8'
 /usr/lib/gcc/powerpc64le-linux-gnu/5/cc1plus -fpreprocessed main.ii
-msecure-plt -quiet -dumpbase main.cpp -mcpu=power8 -auxbase main -std=c++11
-version -fstack-protector-strong -Wformat -Wformat-security -o main.s
GNU C++11 (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.2) version 5.4.0 20160609
(powerpc64le-linux-gnu)
        compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++11 (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.2) version 5.4.0 20160609
(powerpc64le-linux-gnu)
        compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR
version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: 840114473bcf0205e182c11cebcb2c2e
main.cpp: In function ‘int main(int, char**)’:
main.cpp:5:52: error: cannot convert ‘bool’ to ‘__vector(4) __bool int’ in
initialization

Reply via email to