Can you find out where the code goes wrong?
Lionello Lunesu
lionello at lunesu.remove.com
Sun May 24 21:36:12 PDT 2009
"davidl" <davidl at nospam.org> wrote in message
news:op.uugvg5ahj5j59l at my-tomato...
[snip]
> The culprit is the on stack array.
>
> Should the compiler warn on slicing on a fixed length array? or even give
> an error?
> I find this use case can easily go wrong! You may even think this code is
> correct at the very first glance.
Definately a bug. You should file it to bugzilla.
When returning the original stack-allocated array the compiler correctly
complains:
test.d(25): Error: escaping reference to local v
but as soon as you slice it, even "v[]", it is no longer detected.
Good catch!
L.
More information about the Digitalmars-d
mailing list