Skip to content
Snippets Groups Projects
Commit f437871a authored by dtc's avatar dtc
Browse files

Generate a compiler note if the default initial element for make-array

is not a subtype of the element-type. According to ANSI CL the result
of accessing uninitialised elements is undefined, and currently in
CMUCL it can cause problems not detect in safe code when the default
element not a subtype of the element-type - at least a compiler note
is generated now.
parent d866a888
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/array-tran.lisp,v 1.21 1997/11/01 22:58:26 dtc Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/array-tran.lisp,v 1.22 1998/01/09 10:07:48 dtc Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -238,13 +238,18 @@ ...@@ -238,13 +238,18 @@
`(truly-the ,spec `(truly-the ,spec
(allocate-vector ,typecode length ,nwords-form)))) (allocate-vector ,typecode length ,nwords-form))))
(values (values
(if (and default-initial-element (cond ((and default-initial-element
(or (null initial-element) (or (null initial-element)
(and (constant-continuation-p initial-element) (and (constant-continuation-p initial-element)
(eql (continuation-value initial-element) (eql (continuation-value initial-element)
default-initial-element)))) default-initial-element))))
constructor (unless (csubtypep (ctype-of default-initial-element)
`(truly-the ,spec (fill ,constructor initial-element))) eltype-type)
(compiler-note "Default initial element ~s is not a ~s."
default-initial-element eltype))
constructor)
(t
`(truly-the ,spec (fill ,constructor initial-element))))
'((declare (type index length)))))))) '((declare (type index length))))))))
;;; MAKE-ARRAY -- transform. ;;; MAKE-ARRAY -- transform.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment