[mercury-users] Strange behavior for io__format

Pieter Laeremans pieter at hades.kotnet.org
Wed Dec 4 01:45:47 AEDT 2002


Hi,

I've found io__format to behave strange 


This program: 

:- module simple.
:- interface.

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


:- implementation.


:- import_module string.
:- import_module list.
main -->
	io__write("test"),
	io__format("%s", [s("foo"), s("bar")]).
 

Gives this as a result:

mercury $ ./simple 
"test"Uncaught Mercury exception:
Software Error: string__format: format string invalid.
Stack dump not available in this grade.

When I first encountered the strange behavior I put an empyt string as
the first argument of the  io__format.

But apparently the behaviour can be generalized to the case where more
data are supplied in the second argument, then are used in the first.

Shouldn't the compiler warn for this kind of error ?

Thanks,

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