>>>>> "Christoph" == Christoph Breitkopf <[EMAIL PROTECTED]> writes:

    Christoph> Hello,

    Christoph> I have a problem that the return type from aref does
    Christoph> not agree with the declared element type of the array.
    Christoph> Here is a short test program:

    Christoph> (declaim (optimize (speed 2) (safety 2)
    Christoph>                    (extensions:inhibit-warnings 0)))
 
    Christoph> (defun elem-length (x i)
    Christoph>   (declare (type (simple-array simple-base-string 1) x))
    Christoph>   (let ((s (aref x i)))
    Christoph>     ; (declare (type simple-base-string s))
    Christoph>     (length s)))

[snip]
 
    Christoph> ; In: DEFUN ELEM-LENGTH
 
    Christoph> ;   (LENGTH S)
    Christoph> ; Note: Unable to optimize due to type uncertainty:
    Christoph> ;     The first argument is a (OR NULL VECTOR CONS), not a 
(SIMPLE-ARRAY * (*)).
    Christoph> ;
    Christoph> ; Note: Unable to optimize due to type uncertainty:
    Christoph> ;     The first argument is a (OR NULL VECTOR CONS), not a VECTOR.
    Christoph> ;
    Christoph> ; Note: Forced to do static-function Length (cost 52).
    Christoph> ;     Unable to do LENGTH/LIST (cost 40) because:
    Christoph> ;     The first argument is a (OR NULL VECTOR CONS), not a LIST.
    Christoph> ...

    Christoph> Why does the compiler infer (OR NULL VECTOR CONS) for (aref x i)?

I think this happens because CMUCL doesn't have a specialized array
type for arrays with simple-base-string.  Thus, the actual type of the
array is (simple-array T 1).  Compare with what
upgraded-array-element-type says for simple-base-string.

Earlier versions would trust your declared element-type, but later
versions took this out as being unsafe because the compiler and
runtime couldn't really prove it was true.  For example, you could
call elem-length with any 1D simple-array and bad things could happen
if it wasn't really a (simple-array simple-base-string 1).

Ray

-- 
-- 
Ericsson may automatically add a disclaimer.  Sorry, it's beyond my
control.




This communication is confidential and intended solely for the addressee(s). Any 
unauthorized review, use, disclosure or distribution is prohibited. If you believe 
this message has been sent to you in error, please notify the sender by replying to 
this transmission and delete the message without disclosing it. Thank you.

E-mail including attachments is susceptible to data corruption, interruption, 
unauthorized amendment, tampering and viruses, and we only send and receive e-mails on 
the basis that we are not liable for any such corruption, interception, amendment, 
tampering or viruses or any consequences thereof.

Reply via email to