Re: ecpg compile error on AIX - Mailing list pgsql-hackers

From Tom Lane
Subject Re: ecpg compile error on AIX
Date
Msg-id 9677.1010425207@sss.pgh.pa.us
Whole thread Raw
In response to Re: ecpg compile error on AIX  (Michael Meskes <meskes@postgresql.org>)
Responses Re: ecpg compile error on AIX  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Michael Meskes <meskes@postgresql.org> writes:
> Does it work with this?

>  *((long long int *) ((long long int *)ind + ind_offset*act_tuple)) = variable->len;

> If it does we have to check whether that does what I expect it to.

ind_offset is already a sizeof() measure, isn't it?
I would guess that what you want is

>  *((long long int *) ((char *)ind + ind_offset*act_tuple)) = variable->len;

since ind_offset*act_tuple is a number expressed in bytes, and should
not be scaled up by sizeof(long long int).

Also, if the code works for you at all, it's because GCC is (in
violation of the ANSI C standard) interpreting the construct as
addition to char* rather than addition to void*.  Casting to anything
other than char* will change the behavior.

(Might be a lot easier just to declare ind as char* instead of void*
in the first place...)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Why MemoryContextSwitch in ExecRelCheck ?
Next
From: Laurette Cisneros
Date:
Subject: Re: bug in join?