Is this a bug?
Martin Kahlert
martin.kahlert@infineon.com
Wed Dec 6 03:42:00 GMT 2000
Hi!
I have code similar to this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void f(const char **x)
{
while(*x)
{
puts(*x);
x++;
}
}
int main(int argc,char *argv[])
{
char **buffer;
buffer = calloc(3, sizeof(char*));
buffer[0] = strdup("Hello");
buffer[1] = strdup("World");
f(buffer);
return 0;
}
gcc -Wall -o prog prog.c gives:
t.c: In function `main':
t.c:23: warning: passing arg 1 of `f' from incompatible pointer type
(the warning comes from the missing const)
Is this a bug?
At least it is an inconsistency:
f(const char *buffer)
{
puts(buffer);
}
int main()
{
char b[] = "Hello World";
f(b);
return 0;
}
works without any warning!
Thanks for any clarification,
Martin.
--
The early bird gets the worm. If you want something else for
breakfast, get up later.
More information about the Gcc-bugs
mailing list