Skip to content

Commit

Permalink
fix #11271
Browse files Browse the repository at this point in the history
don't use reinterpret on struct types in fill!
  • Loading branch information
JeffBezanson committed May 21, 2015
1 parent 49d3b6b commit 7c60974
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ end
function fill!{T<:Union(Integer,FloatingPoint)}(a::Array{T}, x)
# note: checking bit pattern
xT = convert(T,x)
if isbits(T) && ((sizeof(T)==1 && reinterpret(UInt8, xT) == 0) ||
(sizeof(T)==2 && reinterpret(UInt16, xT) == 0) ||
(sizeof(T)==4 && reinterpret(UInt32, xT) == 0) ||
(sizeof(T)==8 && reinterpret(UInt64, xT) == 0))
if isbits(T) && nfields(T)==0 &&
((sizeof(T)==1 && reinterpret(UInt8, xT) == 0) ||
(sizeof(T)==2 && reinterpret(UInt16, xT) == 0) ||
(sizeof(T)==4 && reinterpret(UInt32, xT) == 0) ||
(sizeof(T)==8 && reinterpret(UInt64, xT) == 0))
ccall(:memset, Ptr{Void}, (Ptr{Void}, Cint, Csize_t),
a, 0, length(a)*sizeof(T))
else
Expand Down
3 changes: 2 additions & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ static Value *generic_box(jl_value_t *targ, jl_value_t *x, jl_codectx_t *ctx)
if (vxt == T_void)
return vx;
if (!vxt->isSingleValueType()) {
jl_error("box: argument not of a primitive type");
emit_error("reinterpret: expected non-struct value as second argument", ctx);
return UndefValue::get(jl_pvalue_llvmt);
}
if (llvmt == T_int1) {
vx = builder.CreateTrunc(vx, llvmt);
Expand Down

0 comments on commit 7c60974

Please sign in to comment.