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

            Bug ID: 58422
           Summary: vector shift operations work in C but not C++
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabriel at teuton dot org

When operating on vectors, the shift operations <<=, >>=, <<, and >> are
recognized in C but not C++.

#include <stdint.h>

typedef int32_t int32x4_t __attribute__((vector_size(16)));

int32x4_t apply_shift(int32x4_t arg)
{
    int32x4_t s = { 1, 1, 1, 1 };

    arg <<= 1;
    arg = arg << 1;
    arg <<= s;
    arg = arg << s;

    return arg;
}

$ g++ -c -o shift.o shift.cpp
shift.cpp: In function ‘int32x4_t apply_shift(int32x4_t)’:
shift.cpp:9:13: error: invalid operands of types ‘int32x4_t {aka __vector(4)
int}’ and ‘int’ to binary ‘operator<<’
shift.cpp:9:13: error:   in evaluation of ‘operator<<=(int32x4_t {aka
__vector(4) int}, int)’
shift.cpp:10:18: error: invalid operands of types ‘int32x4_t {aka __vector(4)
int}’ and ‘int’ to binary ‘operator<<’
shift.cpp:11:13: error: invalid operands of types ‘int32x4_t {aka __vector(4)
int}’ and ‘int32x4_t {aka __vector(4) int}’ to binary ‘operator<<’
shift.cpp:11:13: error:   in evaluation of ‘operator<<=(int32x4_t {aka
__vector(4) int}, int32x4_t {aka __vector(4) int})’
shift.cpp:12:18: error: invalid operands of types ‘int32x4_t {aka __vector(4)
int}’ and ‘int32x4_t {aka __vector(4) int}’ to binary ‘operator<<’

Works fine in C:
$ gcc -c -x c -o shift.o shift.cpp
(no error)

$ g++ --version | head -n 1
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
$ uname -m -p
x86_64 x86_64

Reply via email to