[m-rev.] diff: add a test case for a ppc/os x bug
Julien Fischer
juliensf at cs.mu.OZ.AU
Thu Dec 2 18:05:38 AEDT 2004
Estimated hours taken: 0.1
Branches: main
Add a bug that Ian discovered to the test suite.
XXX We don't have a fix for this yet.
tests/hard_coded/Mmakefile:
tests/hard_coded/ppc_bug.exp:
tests/hard_coded/ppc_bug.m:
Add a test case that currently compiles incorrectly in
grade reg.gc on PPC/MacOS X.
Julien.
Index: hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.240
diff -u -r1.240 Mmakefile
--- hard_coded/Mmakefile 8 Nov 2004 02:50:32 -0000 1.240
+++ hard_coded/Mmakefile 2 Dec 2004 06:57:29 -0000
@@ -121,6 +121,7 @@
nondet_copy_out \
nullary_ho_func \
null_char \
+ ppc_bug \
pprint_test \
pprint_test2 \
pragma_c_code \
Index: hard_coded/ppc_bug.exp
===================================================================
RCS file: hard_coded/ppc_bug.exp
diff -N hard_coded/ppc_bug.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hard_coded/ppc_bug.exp 2 Dec 2004 06:53:06 -0000
@@ -0,0 +1 @@
+3
Index: hard_coded/ppc_bug.m
===================================================================
RCS file: hard_coded/ppc_bug.m
diff -N hard_coded/ppc_bug.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hard_coded/ppc_bug.m 2 Dec 2004 06:55:59 -0000
@@ -0,0 +1,40 @@
+% The following program compiles incorrectly on PPC/MacOS X
+% in grade reg.gc. find_nth_yes/4 ends up throwing an
+% exception instead of returning `YesPos = 3'. Passing
+% `--no-optimize-fulljumps' to causes the test to pass.
+%
+% The test passes with gcc 2.95.2 (Apple version)
+% but fails with gcc 3.3 (Apple version).
+
+:- module ppc_bug.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module list, int, bool, std_util, exception.
+
+main(!IO) :-
+ find_nth_yes([yes, no, yes, yes], 2, 1, X),
+ io.write_int(X, !IO),
+ io.nl(!IO).
+
+:- pred find_nth_yes(list(bool)::in, int::in, int::in, int::out) is det.
+
+find_nth_yes([], _, _, _) :- throw("no").
+find_nth_yes([B | Bs], N, Cur, YesPos) :-
+ (
+ B = no,
+ find_nth_yes(Bs, N, Cur + 1, YesPos)
+ ;
+ B = yes,
+ ( N = 1 ->
+ YesPos = Cur
+ ;
+ find_nth_yes(Bs, N - 1, Cur + 1, YesPos)
+ )
+ ).
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list