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

            Bug ID: 67896
           Summary: Inconsistent behaviour between C and C++ for types
                    poly8x8_t and poly16x8_t
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roger.ferrer at bsc dot es
  Target Milestone: ---
            Target: aarch64-linux-gnu

Hi,

aarch64-linux-gnu-gcc is able to distinguish Neon poly types "poly8x8_t" and
"poly16x8_t" but aarch64-linux-gnu-g++ seems it can't.

The following snippet

-- test.c
#include <arm_neon.h> 

void f(poly8x8_t *a, poly16x8_t *b)
{
    a = b;
}
-- end of test.c

triggers a warning in C

$ aarch64-linux-gnu-gcc -Wall -c test.c
test.c: In function ‘f’:
test.c:5:7: warning: assignment from incompatible pointer type
[-Wincompatible-pointer-types]
     a = b;
       ^

but is accepted without complaints in C++

$ aarch64-linux-gnu-g++ -x c++ -Wall -c test.c
<no warnings or errors>

A more elaborated C++11 testcase reveals that these two types are mostly equal
except for sizeof.

-- testcxx11.cc
#include <arm_neon.h>

typedef poly8x8_t T;
typedef poly16x8_t T; // this is OK in C++ if they are the same type

template <typename T, typename S>
struct Equal;

template <typename T>
struct Equal<T, T>
{
    typedef int X;
};

Equal<poly8x8_t, poly16x8_t>::X x;

static_assert(sizeof(poly8x8_t) == sizeof(poly16x8_t), "");
-- end of testcxx11.cc

In this example, g++ only complains about their sizeof being different (8 and
16 respectively)

$ aarch64-linux-gnu-g++ -Wall -std=c++11 -c testcxx11.cc 
testcxx11.cc:17:1: error: static assertion failed: 
 static_assert(sizeof(poly8x8_t) == sizeof(poly16x8_t), "");
 ^

Kind regards,

Reply via email to