[m-dev.] for review: runtime fixes

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 9 16:37:43 AEST 1999


> > +	printf("allocated %ld words at %p\n", (unsigned long) val, addr);
> 
> The format specifier "%p" expects a `void *', but you're passing an
> `unsigned long'.

No, I am not. %ld is the first arg; %p is the second. The variable
addr is of type Word *.

Of course, the %ld should be %lu; I will change that.

> > +MR_print_heapptr(FILE *fp, const Word *s)
> > +{
> > +#ifdef	CONSERVATIVE_GC
> > +	fprintf(fp, "heap %ld (%p)",
> > +		(long) s, (const void *) s);
> 
> It's probably better to use `%lu' rather than `%ld' and to cast to
> `unsigned long' rather than `long'.

That would not be helpful for bugs in which the program tried to
access the heap at negative offsets. I seem to recall that way back
in the mists of time, we actually had such bugs, although probably
with the stacks and not the heap.

Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list