[mdlug] C Pointer Problem
Aaron Kulkis
akulkis00 at gmail.com
Mon Apr 13 17:42:22 EDT 2015
A. Zimmer wrote:
> 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.
Code should have been written as sometype * arrayname[elements];
instead of someint32 * arrayname[elements];
That kind of programming in C (declaring pointers as int) was supposed
to have been eradicated by the mid 1980's. Gimp didn't even start until
sometime around 2000. And this being a plugin, even later than that.
Original programmer (not you) should be found and treated as follows
do {
hit with a clue-by-four
} while (! (declares_pointers_as ("typename *") );
just saying.
>
> 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.
>
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>
More information about the mdlug
mailing list