<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><font face="Courier">I have some trouble interpreting the
        float-to-word/word-to-float conversion issue in the particular
        case of array initialisation.</font></p>
    <p><font face="Courier">This is performed by
        'ML_init_array(MR_ArrayPtr array, MR_Integer size, MR_Word
        item)'  (DEV branch, array.m:1007), using an MR_Word initialiser
        'item' in a simple loop:</font></p>
    <p><font face="Courier">        for (i = 0; i < size; i++) {<br>
                    array->elements[i] = item;<br>
                }</font></p>
    <p><font face="Courier">Now, the manual says that some
        implementations have sizeof(MR_Float) > sizeof(MR_Word),
        which is why lists of floats should be converted using
        'MR_word_to_float', as explained in the (snapshot) manual (p.
        109):</font></p>
    <p><font face="Courier">    "The following fragment of C code
        illustrates the correct way to extract the head of a<br>
            Mercury list of floats.<br>
            MR_Float f;<br>
            f = MR_word_to_float(MR_list_head(list));<br>
            Omitting the call to MR_word_to_float in the above example
        would yield incorrect<br>
            results for implementations where ‘sizeof(MR_Float)’ is
        greater than ‘sizeof(MR_Word)’."<br>
      </font></p>
    <p><font face="Courier">A cursory look at runtime/mercury_float.h
        points to it being necessary when MR_BOXED_FLOAT is defined.</font></p>
    <p><font face="Courier">So one would expect that the initialiser
        'item', if of float type (i.e. in an 'array(float)'), would be
        checked as not exceeding the upper bound to MR_Word, when
        entered in init_2/3 (array.m:1494), at least if MR_BOXED_FLOAT
        is defined elsewhere. If this is the case, my guess is that the
        float initialiser item will not be passed unharmed to the above
        loop (behaviour may possibly be undefined).<br>
      </font></p>
    <p><font face="Courier">The code in array.m has been too stable and
        polished for over 20 years now for it to be a real bug, so it
        must be that I did not catch something. <br>
      </font></p>
    <p><font face="Courier">Thanks for giving me a hint.</font></p>
    <p><font face="Courier">F. N.</font><br>
    </p>
    <p><br>
    </p>
  </body>
</html>