[m-rev.] diff: add a sanity check on stack size.

Ralph Becket rbeck at microsoft.com
Wed Aug 22 20:15:33 AEST 2001


> From: Tyson Dowd [mailto:trd at miscrit.be]
> Sent: 22 August 2001 11:05
> 
> Index: compiler/ilds.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ilds.m,v
> retrieving revision 1.10
> diff -u -r1.10 ilds.m
> --- compiler/ilds.m	13 Aug 2001 01:39:31 -0000	1.10
> +++ compiler/ilds.m	22 Aug 2001 10:09:03 -0000
> @@ -439,6 +439,13 @@
>  	;
>  		NewCurrent = Current + get_stack_difference(I),
>  		NewMax = max(NewCurrent, Max)
> +	),
> +		% This is a sanity check, the stack should never have a
> +		% negative size.
> +	( NewCurrent < 0 ->
> +		error("stack underflow while calculating max stack")
> +	;
> +		true
>  	).

The following is shorter and arguably clearer:

    require(NewCurrent >= 0, "stack underflow while calculating max
stack")

- Ralph
--------------------------------------------------------------------------
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