S
subramanian100in
Consider the following program x.c:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int x[10];
int **pp = &x;
pp = NULL; // just to get rid of compiler warning.
return EXIT_SUCCESS;
}
When I compile this program under gcc 3.4.3 as
gcc -std=c99 -pedantic -Wall -Wextra x.c
it merely generates the warning
x.c: In function `main':
x.c:7: warning: initialization from incompatible pointer type
I thought the line
int **pp = &x;
is in error because of different pointer types involved in the
assignment - '&x' is a pointer to an array and 'pp' is a pointer to
pointer.
So I do not understand why the compiler did not generate error for
this line.
Is this behaviour specific to the particular gcc implementation or the
ISO C99 Standard itself does not treat the above assignment as an
error ?
Please clarify.
Thanks
V.Subramanian
#include <stdlib.h>
#include <stdio.h>
int main()
{
int x[10];
int **pp = &x;
pp = NULL; // just to get rid of compiler warning.
return EXIT_SUCCESS;
}
When I compile this program under gcc 3.4.3 as
gcc -std=c99 -pedantic -Wall -Wextra x.c
it merely generates the warning
x.c: In function `main':
x.c:7: warning: initialization from incompatible pointer type
I thought the line
int **pp = &x;
is in error because of different pointer types involved in the
assignment - '&x' is a pointer to an array and 'pp' is a pointer to
pointer.
So I do not understand why the compiler did not generate error for
this line.
Is this behaviour specific to the particular gcc implementation or the
ISO C99 Standard itself does not treat the above assignment as an
error ?
Please clarify.
Thanks
V.Subramanian