[mercury-users] Mercury program loops for ever with rotd-2003-02-23

Ian MacLarty maclarty at cs.mu.OZ.AU
Tue Mar 8 16:23:40 AEDT 2005


Michael Day wrote:
> Hi,
> 
> The following construct causes a program compiled with rotd-2003-02-23 to
> loop for ever until it segfaults:
> 
>     ( if my_function(X) > Max then
> 	...
> 
> where my_function is a det function that doesn't do anything weird.
> 
> If the program is rewritten like this:
> 
>     Y = my_function(X),
>     ( if Y > Max then
>         ...
> 
> then everything works fine.
> 
> Has anyone else experienced this extremely odd behaviour with
> rotd-2003-02-23? I can attempt to create a decent test case if this bug is
> unfamiliar.
> 

I've run the following program on the current unstable rotd and it 
didn't loop:

:- module loop.

:- interface.

:- import_module io.

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

:- implementation.

:- import_module int.

main(!IO) :-
         Max = 10,
         X = 5,
         ( if my_func(X) > Max then
                 io.write("yes", !IO)
         else
                 io.write("no", !IO)
         ),
         nl(!IO).

:- func my_func(int) = int.

my_func(X) = X + 1.

Would you mind checking if the bug still occurs on the current unstable 
rotd and if it does please submit a test case along with the compilation 
options.

Cheers,
Ian.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list