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

            Bug ID: 87307
           Summary: Implicit conversion from int to vector works, explicit
                    is an error
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzi...@poradnik-webmastera.com
  Target Milestone: ---

Vector types defined using __attribute((vector_size(N))) supports implicit
conversion from int to vector type for arithmetic operators. However when you
try to perform explicit conversion, you will gen an error. Please add support
for explicit conversion from int to vector type, it would be handy.

typedef int VInt __attribute((vector_size(32)));

VInt test1(VInt v)
{
    return v + 2; // OK
}

VInt test2(VInt v)
{
    return v + (VInt)2; // error: can't convert a value of type 'int' to vector
type 'VInt' {aka '__vector(8) int'} which has different size
}

VInt test3(VInt v)
{
    VInt v2(2); // error: cannot convert 'int' to 'VInt' {aka '__vector(8)
int'} in initialization
    return v + v2;
}

Reply via email to