Andrej Mitrovic <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #1 from Andrej Mitrovic <> 2011-05-26 
13:21:31 PDT ---
This will be caught in non-release builds, simply because copy calls put(),
which calls front(target), where front() has this assert:
  assert(a.length, "Attempting to fetch the front of an empty array");

The assert goes away in release, which means if you compile the following with
-release the enforce will pass since memory will get overwritten:

import std.algorithm;
import std.exception;

void main()
    // compile with -release
    auto a = [1, 2, 3, 4, 5];
    int[] b = new int[3];

    copy(a, b);
    enforce(b[3] == 4);  // oops..

If we add your changes it means debug builds will end up doing double checks,
once in copy() where it would check for "!target.empty" (which I think should
actually be expression "target.length"), and once in the call to front() by the
put() function.

I'm not sure what, if anything should be done about this. Personally I would
only expect the possibility of this kind of memory corruption if I pass the
-noboundscheck switch. Anyone else care to share their opinion?

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to