Bug 96990 - Regression in aarch64 struct vector member initialization
Summary: Regression in aarch64 struct vector member initialization
Status: RESOLVED DUPLICATE of bug 96377
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2020-09-09 02:41 UTC by Yichao Yu
Modified: 2020-09-10 17:21 UTC (History)
1 user (show)

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yichao Yu 2020-09-09 02:41:11 UTC
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;
}
```
Comment 1 Andrew Pinski 2020-09-09 06:29:10 UTC
I think it was only broken for GCC 10.2.0 and has already been fixed.
Comment 2 rsandifo@gcc.gnu.org 2020-09-10 17:21:17 UTC
Yeah, this was fixed by https://gcc.gnu.org/g:7d599ad27b9bcf5165f87710f1abc64bbabd06ae, which will be included in GCC 10.3.

Sorry for the inconvenience.

(PR96377 is still open because there's a related unfixed bug on trunk, but the current GCC 10 branch is unaffected.)

*** This bug has been marked as a duplicate of bug 96377 ***