[m-users.] accumulator introduction in HLC

Matthias Güdemann matthias.guedemann at googlemail.com
Wed Jun 10 00:03:37 AEST 2015


Hi,

I have a program that produces Address boundary errors when compiled in
the hlc.gc grade using Mercury 14.01.1. It contains the following:

,----
| :- func get_range(int, int) = list(int).
| :- pred get_range(int::in, int::in, list(int)::in, list(int)::out) is det.
| 
| get_range(Curr, Max, Acc, OutList) :-
|     ( Curr < Max ->
|         get_range(Curr + 1, Max, [Curr | Acc], OutList)
|     ;
|         OutList = reverse([Curr | Acc])
|     ).
| 
| get_range(Curr, Max) = Res :-
|     ( Curr > Max ->
|         Res = []
|     ;
|         Res = [Curr | get_range(Curr + 1, Max)]
|     ).
`----

When using the function for lists of size 400000 or so, this produces
the above error, when compiling using 'mmc -mrH', adding
'--introduce-accumulators' to the compile options does not change the
outcome.

Compiling in 'asm.fast.gc' works with and without the
'--introduce-accumulators' option; using the predicate version of
'get_range' works in both grades.

What is the problem here? Shouldn't '--introduce-accumulators' take care
of this?

Matthias



More information about the users mailing list