V
vippstar
Today I got a confusing message from gcc (I'm aware, those don't break
conformance ;-)
In function 'main':
7: warning: format '%d' expects type 'int', but argument 2 has type
'char (*)[1u]'
The code is
#include <stdio.h>
int main(void) {
char p[3][2];
printf("%d\n", &p[0]); /* this is errornous, but it's on purpose
there to generate the warning */
return 0;
}
I'm curious, what is gcc talking about?
Why is &p[0] a char (*)[1u]?
My first guess was that char (*)[N] pointers get promoted to char (*)
[1] pointers in VLA arguments. (it doesn't make much sense to me
though)
Can anyone explain (don't answer with a yes; actually do so gcc's
behavior here?
conformance ;-)
In function 'main':
7: warning: format '%d' expects type 'int', but argument 2 has type
'char (*)[1u]'
The code is
#include <stdio.h>
int main(void) {
char p[3][2];
printf("%d\n", &p[0]); /* this is errornous, but it's on purpose
there to generate the warning */
return 0;
}
I'm curious, what is gcc talking about?
Why is &p[0] a char (*)[1u]?
My first guess was that char (*)[N] pointers get promoted to char (*)
[1] pointers in VLA arguments. (it doesn't make much sense to me
though)
Can anyone explain (don't answer with a yes; actually do so gcc's
behavior here?