This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc strcpy pseudo bug or detail


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]