Skip to content

zeros function mutates arguments #19265

@jw3126

Description

@jw3126

I was surprised by zeros sometimes mutating an array, I guess this is not intended:

x = [1.];
zeros(Float64, x);
x
1-element Array{Float64,1}:
 0.0

while

x = [1.];
zeros(x);
x
1-element Array{Float64,1}:
 1.0
Julia Version 0.6.0-dev.1202
Commit 42a22b6 (2016-11-06 22:14 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions