[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Implicition declarations of functions and bugs

On 3/11/06, Goswin von Brederlow <brederlo@informatik.uni-tuebingen.de> wrote:

> > $ gcc-3.3 -c -g -O -Wall t.c
> > t.c: In function `foo':
> > t.c:4: warning: implicit declaration of function `strdup'
> > t.c:4: warning: return makes pointer from integer without a cast
> (all asm is from amd64)
> 0000000000400500 <foo>:
>   400500:       48 83 ec 08             sub    $0x8,%rsp
>   400504:       31 c0                   xor    %eax,%eax
>   400506:       e8 d5 fe ff ff          callq  4003e0 <strdup@plt>
>   40050b:       48 83 c4 08             add    $0x8,%rsp
>   40050f:       48 98                   cltq
>   400511:       c3                      retq
> The return value of strdup is passed back unaltered. No crash.

The context of this discussion was ia64, but I realize now that this
probably wasn't obvious for debian-devel subscribers.  I should have
been clear about that.  In any case, ia64 calling convention say that
a 32-bit integer value in a (64-bit) register may contain garbage in
the top 32 bits, hence the result from a function returning "int" will
be sign- or zero-extended when converted to a 64-bit value, hence the

Mosberger Consulting LLC, http://www.mosberger-consulting.com/

Reply to: