32-bit truncation of 64-bit values

Peter Jeremy peterjeremy at optushome.com.au
Sun Mar 1 11:31:21 PST 2009


On 2009-Feb-28 13:06:41 +0000, Dieter <freebsd at sopwith.solgatos.com> wrote:
>> Having just tracked down an issue caused by a pointer-to-int truncation,
>
>Was this in C?  Didn't the compiler complain?

Yes and no.  It wasn't as obvious as your example, rather it was missing
function prototypes.  After unrolling macros, the offending code did:

int     input_line;
int     cursor = 0;
extern  void    putchar_x();
extern  char    *CM;
...
	tputs(tgoto(CM, cursor, input_line), 0, putchar_x);
...
without <curses.h>, <term.h> or other prototypes.  As a result,
tgoto() was implicitly assumed to return (int) instead of (char *) -
which doesn't produce any warning unless compiled with -Wall.

(If you want to experiment, this is ports/irc/blackened - the above
code is in source/input.c, though there seem to be several other
similar problems in the code, resulting in the current BROKEN flag).

-- 
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20090301/b740bf2c/attachment.pgp


More information about the freebsd-amd64 mailing list