From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Subject: Re: Pointer problems
Date: Fri, 6 Aug 1999 23:30:56 -0600 (MDT) [thread overview]
Message-ID: <199908070530.XAA12527@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <00e301bee08a$59798f40$0101a8c0@netcobra.com> from "Tommy Cheung" at Aug 7, 99 12:07:21 pm
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
next prev parent reply other threads:[~1999-08-07 5:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-05 7:32 Tru64 executeables Bernhard Gschaider
1999-08-05 7:58 ` Greg Lindahl
1999-08-05 8:05 ` John Connett
1999-08-05 13:01 ` Christopher C Chimelis
1999-08-05 8:40 ` Angus Leeming
1999-08-05 11:03 ` Dave Mason
1999-08-05 11:29 ` Matti Aarnio
1999-08-05 16:25 ` Greg Lindahl
1999-08-06 8:46 ` Ivan Kokshaysky
1999-08-06 10:52 ` Roman Martonak
1999-08-06 18:22 ` Greg Lindahl
1999-08-06 19:36 ` Jim Gettys
1999-08-06 20:31 ` Jim Gettys
1999-08-06 23:13 ` Greg Lindahl
1999-08-07 1:28 ` Richard Henderson
1999-08-07 1:30 ` Greg Lindahl
1999-08-07 2:53 ` Greg Lindahl
1999-08-07 4:07 ` Pointer problems Tommy Cheung
1999-08-07 5:30 ` Michal Jaegermann [this message]
1999-08-07 6:54 ` Tru64 executeables Ivan Kokshaysky
1999-08-07 7:04 ` Greg Lindahl
1999-08-07 21:29 ` Richard Henderson
1999-08-07 21:52 ` Dave Mason
1999-08-07 22:03 ` Greg Lindahl
1999-08-07 22:27 ` Greg Lindahl
1999-08-09 13:01 ` Phil Carmody
1999-08-09 17:02 ` Greg Lindahl
1999-08-09 17:22 ` Ivan Kokshaysky
1999-08-09 17:27 ` Phil Carmody
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox