[m-dev.] IL grade broken

Peter Ross pro at missioncriticalit.com
Wed Dec 3 20:05:29 AEDT 2003


I have constructed a test case which shows the problem.

Building the attached files in use_ft.m and ft.m.

mmake GRADE=hlc.gc MCFLAGS=--no-line-numbers use_ft.depend
mmake GRADE=hlc.gc MCFLAGS=--no-line-numbers use_ft

we obtain the following function prototype in use_ft.c

MR_bool MR_CALL use_ft____Unify____ft_0_0(
    MR_Box use_ft__HeadVar__1_1,
    MR_Box use_ft__HeadVar__2_2);

However no actual function is generated on the C backend because the
body is marked external.  So what we end up with is a function prototype
for a function which doesn't exist, a bug but not a catastrophic one.

However on the il backend it is catastrophic bug because we actually do
generate some code, it is just that this code is completely incorrect
and does cause a compilation error.

Does this help?
-------------- next part --------------
%------------------------------------------------------------------------------%
% use_ft.m
% Peter Ross <pro at missioncriticalit.com>
% Wed Dec  3 09:33:20 RST 2003
% vim: ft=mercury ff=unix ts=4 sw=4 et tw=0 wm=0
%
%------------------------------------------------------------------------------%

:- module use_ft.

:- interface.

:- import_module io.

:- pred main(io::di, io::uo) is det.

%------------------------------------------------------------------------------%
%------------------------------------------------------------------------------%

:- implementation.

:- import_module ft.

%------------------------------------------------------------------------------%

main(!IO) :-
	A = create_ft(1),
	B = create_ft(2),
	( A = B ->
		io__write_string("true.\n", !IO)
	;
		io__write_string("false.\n", !IO)
	).

%------------------------------------------------------------------------------%
%------------------------------------------------------------------------------%
-------------- next part --------------
%------------------------------------------------------------------------------%
% ft.m
% Peter Ross <pro at missioncriticalit.com>
% Wed Dec  3 09:28:19 RST 2003
% vim: ft=mercury ff=unix ts=4 sw=4 et tw=0 wm=0
%
%------------------------------------------------------------------------------%

:- module ft.

:- interface.

:- type ft.

:- func create_ft(int) = ft.

:- implementation.

:- pragma foreign_type(c, ft, "int") where equality is unify_ft.
:- pragma foreign_type(il, ft, "valuetype [mscorlib]System.Int32")
		where equality is unify_ft.

:- pred unify_ft(ft::in, ft::in) is semidet.

:- pragma foreign_proc("C", unify_ft(X::in, Y::in), [promise_pure],
"
	SUCCESS_INDICATOR = (X == Y);
").
:- pragma foreign_proc("C#", unify_ft(X::in, Y::in), [promise_pure],
"
	SUCCESS_INDICATOR = (X == Y);
").

:- pragma foreign_proc("C", create_ft(X::in) = (Y::out), [promise_pure],
"
	Y = X;
").
:- pragma foreign_proc("C#", create_ft(X::in) = (Y::out), [promise_pure],
"
	Y = X;
").


More information about the developers mailing list