https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96990
Bug ID: 96990 Summary: Regression in aarch64 struct vector member initialization Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com Target Milestone: --- The following code used to work on gcc 9.3 but stops working with 10.2 with an error ``` a.c: In function ‘test_aa64_vec_2’: a.c:19:24: error: incompatible types when initializing type ‘signed char’ using type ‘int8x8_t’ 19 | struct_aa64_3 x = {v1 + v1, v2 - v2}; | ^~ a.c:19:33: error: incompatible types when initializing type ‘signed char’ using type ‘float32x2_t’ 19 | struct_aa64_3 x = {v1 + v1, v2 - v2}; | ^~ ``` Any one of the "working" version or compiling with c++ works. >From the error message it seems that GCC correctly inferred the return type of the `v1 + v1` or `v2 - v2` but instead got confused about the field type. Reverssing the order of `v1` and `v2` in the struct causes the error to change to `float` instead of `signed char` so it seems that gcc thinks the code is trying to initialize the first vector member (with element type of `signed char` or `float` instead). I thought such initialization should have an additional `{}` instead... Given that explicit casting or compiling in c++ mode helps I think this is a bug... ``` #include <arm_neon.h> typedef struct { int8x8_t v1; float32x2_t v2; } struct_aa64_3; struct_aa64_3 test_aa64_vec_2(int8x8_t v1, float32x2_t v2) { // works /* int8x8_t vi8 = v1 + v1; */ /* float32x2_t vf = v2 - v2; */ /* struct_aa64_3 x = {vi8, vf}; */ // works /* struct_aa64_3 x = {(int8x8_t)(v1 + v1), (float32x2_t)(v2 - v2)}; */ // not struct_aa64_3 x = {v1 + v1, v2 - v2}; return x; } ```