title: Broadcasting allocates a lot of memory whist for loop doesn't
body: <p>If I have following two variants to write a part of my code and I generally prefer a shorter one. This is the reason why I do like dot-broadcasting in Julia. However I have this example shows that there's something wrong with it.</p>
  <pre><code>function test1(A)
      n = size(A, 2)
      for k in 1:n
          for i in k+1:n
              A[i, k] /= A[k, k]
          end
      end
      A
  end
  
  function test2(A)
      n = size(A, 2)
      for k in 1:n
          A[k+1:n, k] ./= A[k,k]
      end
      A
  end
  
  A = rand(10000,10000)
  B = copy(A)
  @allocated test1(B) # returns 0
  C = copy(A)
  @allocated test2(C) # returns 401131136
  C == B # returns true
  </code></pre>
  <p>Moreover I tried to eliminate syntactic sugar and wrote one more test function</p>
  <pre><code>function test3(A)
      n = size(A, 2)
      for k in 1:n
          broadcast!(/, A[k+1:n, k], A[k+1:n, k], A[k,k])
      end
      A
  end
  </code></pre>
  <p>And this one allocates twice as much memory as <code>test2</code> and... returns wrong result.</p>
  <p>Why does <code>test3</code> return wrong result, and what's wrong with broadcasting, are there any guides explaining how to use it?</p>