[m-dev.] Compiling with LLVM-GCC

Magnus Holm judofyr at gmail.com
Mon Aug 8 05:00:07 AEST 2011

On Sun, Aug 7, 2011 at 19:51, Julien Fischer
<juliensf at csse.unimelb.edu.au> wrote:
> Hi,
> On Sun, 7 Aug 2011, Magnus Holm wrote:
>>> 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 think the problem is likely llvm-gcc itself.  After preprocessing
> one of the expressions that it is complaining isn't constant is:
>     (((MR_Word *)((char *)(((0) << 2)) + ((0)))))
> and that most certainly is contant.  (GCC has no problem with the above
> which is odd because llvm-gcc uses the GCC frontend.)
> Julien.

According to C99:

  An address constant is a null pointer, a pointer to an lvalue
designating an object of static storage duration, or a pointer to a
function designator; it shall be created explicitly using the unary &
operator or an integer constant cast to pointer type, or implicitly by
the use of an expression of array or function type. The
array-subscript [] and member-access . and -> operators, the address &
and indirection * unary operators, and pointer casts may be used in
the creation of an address constant, but the value of an object shall
not be accessed by use of these operators.

The "or an integer constant cast to pointer type"-part seems to
indicate that this is in fact a constant expression.

Anyway, is there a way around this? Would (MR_Word *)((p)+(t)*4)) or
something be equal?

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