From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 10789 invoked from network); 7 Aug 1999 05:31:05 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 7 Aug 1999 05:31:05 -0000 Received: from ellpspace.math.ualberta.ca (michal@ellpspace.math.ualberta.ca [129.128.88.19]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id BAA20234 for ; Sat, 7 Aug 1999 01:31:04 -0400 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id XAA12527 for axp-list@redhat.com; Fri, 6 Aug 1999 23:30:56 -0600 From: Michal Jaegermann Message-Id: <199908070530.XAA12527@ellpspace.math.ualberta.ca> Subject: Re: Pointer problems To: axp-list@redhat.com Date: Fri, 6 Aug 1999 23:30:56 -0600 (MDT) In-Reply-To: <00e301bee08a$59798f40$0101a8c0@netcobra.com> from "Tommy Cheung" at Aug 7, 99 12:07:21 pm Content-Type: text Tommy Cheung wrote: > > I think this might be a common problem with programs between 32bit and > 64bit. Not really - with a minimum care. .... > > ptr = (char *)strchr(machine, ':'); > > when complie we got this > > bbnet.c:93: warning: cast to pointer from integer of different size You do not really say which line is 93 but from the context, most likely, you forgot to include headers with declarations of functions like malloc(), strchr() and the like. If a declaration is missing then C, by default, assumes that such function returns 'int' and you really wanted a pointer here. You see more such code and you start understand those who claim that any explicit casts are evil. Note that the code was incorrect in a 32-bit case as well even if happened to work there due to lucky circumstances. > Any ideas? Compiling, especially on Alpha, without -Wall at miminum (there are warnings not covered by "all") is a very unwise practice. You would be clearly told what was missing otherwise. A common real problem are assumptions that you may store pointer into 'int' and later recover from there the whole address intact. This may be not so easy to fix in a bigger code because of a network of interdependencies. Also passing a pointer to function where int was expected, or vice-versa, and a prototype is missing leads to a "barrel-of-laugh" problems with a stack totally wacko. You will be likely hit not immediately where the bug is but quite a bit later and results can be anything. Michal