This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc strcpy pseudo bug or detail
- From: Phil Edwards <phil at jaj dot com>
- To: Mauricio Labra <mauricio dot labra at construmart dot cl>
- Cc: bug-gcc at gnu dot org, gcc at gcc dot gnu dot org
- Date: Fri, 18 Oct 2002 17:37:27 -0400
- Subject: Re: gcc strcpy pseudo bug or detail
- References: <A768CE0B2654F646B4E2C5BBC439A82A168D64@omega.construmart.cl>
On Thu, Oct 17, 2002 at 11:21:52AM -0400, Mauricio Labra wrote:
>
> #include <stdio.h>
> #include <string.h>
>
> int main()
> {
> char tmp[80];
>
> strcpy(tmp,msg());
> puts(tmp);
> return(0);
> }
>
> char *msg()
> {
> return("Mensaje de prueba");
> }
>
> This sample have a warnings...
>
> # gcc -O3 -Wall x.c
These warnings:
> x.c: In function `main':
> x.c:9: warning: implicit declaration of function `msg'
> x.c:9: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
> x.c:9: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
> x.c:9: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
> x.c:9: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
> x.c:9: warning: passing arg 2 of `strcpy' makes pointer from integer without a cast
are explained by this one:
> x.c: At top level:
> x.c:15: warning: type mismatch with previous implicit declaration
> x.c:9: warning: previous implicit declaration of `msg'
> x.c:15: warning: `msg' was previously implicitly declared to return `int'
>
>
> Whats are the warnings "makes pointer from integer without a cast" of strlen or memcpy functions?
> I don't use this functions !
This is the wrong mailing list to ask such questions; you need a book on
how to program C. (Hint: at line 9, msg() has not been declared, so the
C language assumes it returns int.)
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002