void fn()
{
int *a = &(int[1]){0};
int *b = &(int){0};
}
test.c(3): Error: `[0]` is not an lvalue and cannot be modified
test.c(4): Error: cannot modify constant `0`
array one works if & is removed
int one should be the same as taking the address of a local variable typed "int"
Comment #1 by bugzilla — 2022-09-23T08:48:51Z
clang gives a warning:
test.c:4:7: warning: incompatible pointer types initializing 'int *' with an expression of type 'int (*)[1]' [-Wincompatible-pointer-types]
int *a = &(int[1]){0};
Comment #2 by bugzilla — 2023-04-09T06:01:04Z
The first line compiles successfully now. The second one does not.
Comment #3 by robert.schadek — 2024-12-13T19:22:25Z