1 static int *a = &(int){ 1 }; // OK
2 static int *b = &(int){ *a }; // KO
3
4 static void foo(void)
5 {
6 int *b = &(int){ 1 }; // OK
7 int *c = &(int){ *a }; // OK
8 static int *d = &(int){ 1 }; // KO
9 }
10
11 /*
12 * check-name: compound literal address constness verification
13 * check-command: sparse -Wconstexpr-not-const $file
14 *
15 * check-error-start
16 constexpr-compound-literal.c:2:25: warning: non-constant initializer for static object
17 constexpr-compound-literal.c:8:27: warning: non-constant initializer for static object
18 * check-error-end
19 */
|
1 static int *a = &(int){ 1 }; // OK
2 static int *b = &(int){ *a }; // KO
3
4 static void foo(void)
5 {
6 int *b = &(int){ 1 }; // OK
7 int *c = &(int){ *a }; // OK
8 static int *d = &(int){ 1 }; // KO
9 }
10
11 /*
12 * check-name: constexpr compound literal address
13 * check-command: sparse -Wconstexpr-not-const $file
14 *
15 * check-error-start
16 constexpr-compound-literal.c:2:25: warning: non-constant initializer for static object
17 constexpr-compound-literal.c:8:27: warning: non-constant initializer for static object
18 * check-error-end
19 */
|