[mdlug] C Pointer Problem

A. Zimmer andrew.zimmer at comcast.net
Sun Apr 12 13:27:33 EDT 2015


On Sat, 11 Apr 2015 18:00:05 -0400
Aaron Kulkis <akulkis00 at gmail.com> wrote:

> 
> Try changing the type of the flags field from 32-bit to 64-bit
> 

It turns out that this particular change was unnecessary.

Unless one understands exactly how a program operates, which
in this case I do not, it is not a good idea to change data
types in a willy-nilly fashion.  Unintended side effects
could be produced that would only complicate things further.

The problem with this code is that an array of 32-bit integers
is being used to store pointer values.  Once I realized that
this was happening I simply changed the array type from int32_t
to int64_t and all was well.

But it was not obvious (at least to me) that this was happening.
Should not pointers be stored in an array of void pointers?
If the author had done that, then there would have been no
problem to begin with.

Also, the program cannot be compiled without using the -fno-strict-aliasing
flag, which would indicate that the author is mixing pointer types
or other similar methods.



More information about the mdlug mailing list