[Bug c/105510] error: initializer element is not constant
570070308 at qq dot com
gcc-bugzilla@gcc.gnu.org
Mon May 9 12:21:58 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105510
--- Comment #2 from 。 <570070308 at qq dot com> ---
(In reply to Richard Biener from comment #1)
> As a workaround it works with
>
> struct Test t=(struct Test){1, {3, 4}};
>
> I don't think it your way of writing is actually valid though.
Yes, I'm not sure that this is a Bug. I meet this error when I'm using macro to
init a struct. For example:
```test.c
struct Test2
{
long int x;
long int y;
};
struct Test
{
long int x;
struct Test2 t;
};
#define TEST2_INIT(x, y) ((struct Test2){x, y})
#define TEST_INIT(x) ((struct Test){x, TEST2_INIT(1, 2)})
struct Test test=TEST_INIT(0); // error
```
More information about the Gcc-bugs
mailing list