[m-dev.] Compiling with LLVM-GCC
Mark Brown
mark at csse.unimelb.edu.au
Mon Aug 8 17:06:39 AEST 2011
n 07-Aug-2011, Magnus Holm <judofyr at gmail.com> wrote:
> On Sun, Aug 7, 2011 at 17:48, Mark Brown <mark at csse.unimelb.edu.au> wrote:
> > On 07-Aug-2011, Magnus Holm <judofyr at gmail.com> wrote:
> >> Any way to do it without casting integers
> >> to pointers (which is implementation-defined behaviour)?
> >
> > According to the comment just above the definition, no. ?It will eventually
> > be cast to (MR_Word *). ?And it's naturally going to be implementation-
> > defined, since the point of it is to generate code that is appropriate
> > for the particular target platform. ?;-)
>
> Hm? So it's not possible to compile Mercury with LLVM-GCC at all?
I didn't say that - my answer is that it's not possible to compile Mercury
without casting integers to pointers.
On 07-Aug-2011, Magnus Holm <judofyr at gmail.com> wrote:
> Anyway, is there a way around this? Would (MR_Word *)((p)+(t)*4)) or
> something be equal?
No. The intent is to *avoid* having t be multiplied by anything, so there's
two problems with this definition. First, t is multiplied by 4 when it
needs to be left alone, and second, if p is a pointer expression then C will
happily multiply t for you. That second case would explain the segfaults
you saw earlier.
Does it work if you cast p to an integer type that is at least as large as
a pointer, before adding t?
Cheers,
Mark.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list