Created
May 29, 2021 18:12
-
-
Save vathpela/433745dea466b139de4a560535a215fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
random:~/devel/local/test$ gcc -Og -std=gnu2x -Wall -Wextra -Werror -c -o autoconst.o autoconst.c | |
autoconst.c: In function ‘test’: | |
autoconst.c:12:18: error: passing argument 1 of ‘potemkin’ from incompatible pointer type [-Werror=incompatible-pointer-types] | |
12 | potemkin(data0); | |
| ^~~~~ | |
| | | |
| char ** | |
autoconst.c:6:35: note: expected ‘const char **’ but argument is of type ‘char **’ | |
6 | extern void potemkin(const char **data); | |
| ~~~~~~~~~~~~~^~~~ | |
autoconst.c:15:18: error: passing argument 1 of ‘potemkin’ from incompatible pointer type [-Werror=incompatible-pointer-types] | |
15 | potemkin(data1); | |
| ^~~~~ | |
| | | |
| char ** | |
autoconst.c:6:35: note: expected ‘const char **’ but argument is of type ‘char **’ | |
6 | extern void potemkin(const char **data); | |
| ~~~~~~~~~~~~~^~~~ | |
autoconst.c:17:42: error: invalid initializer | |
17 | const typeof(data->data) data2 = data->data; | |
| ^~~~ | |
autoconst.c:18:18: error: passing argument 1 of ‘potemkin’ from incompatible pointer type [-Werror=incompatible-pointer-types] | |
18 | potemkin(data2); | |
| ^~~~~ | |
| | | |
| char * const* | |
autoconst.c:6:35: note: expected ‘const char **’ but argument is of type ‘char * const*’ | |
6 | extern void potemkin(const char **data); | |
| ~~~~~~~~~~~~~^~~~ | |
autoconst.c:20:42: error: invalid initializer | |
20 | typeof(data->data) const data3 = data->data; | |
| ^~~~ | |
autoconst.c:21:18: error: passing argument 1 of ‘potemkin’ from incompatible pointer type [-Werror=incompatible-pointer-types] | |
21 | potemkin(data3); | |
| ^~~~~ | |
| | | |
| char * const* | |
autoconst.c:6:35: note: expected ‘const char **’ but argument is of type ‘char * const*’ | |
6 | extern void potemkin(const char **data); | |
| ~~~~~~~~~~~~~^~~~ | |
cc1: all warnings being treated as errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct data { | |
void *list; | |
char *data[0]; | |
}; | |
extern void potemkin(const char **data); | |
void | |
test(struct data *data) | |
{ | |
const __auto_type data0 = data->data; | |
potemkin(data0); | |
__auto_type const data1 = data->data; | |
potemkin(data1); | |
const typeof(data->data) data2 = data->data; | |
potemkin(data2); | |
typeof(data->data) const data3 = data->data; | |
potemkin(data3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment