[Issue 12625] implicit slicing of RValue static array should be illegal
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu May 8 01:16:28 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12625
--- Comment #2 from monarchdodra at gmail.com ---
(In reply to Jonathan M Davis from comment #1)
> Why just make the implicit slice illegal? Shouldn't it just be illegal to
> slice it at all, since it's guaranteed to be wrong?
I thought about it some more, and there *are* case where you can slice an
rvalue static array, provided you've "used" it by the end of the expression.
EG:
//----
int sum(int[] i)
{
return reduce!"a+b"(i);
}
void main()
{
enum int[3] ints = [1, 2, 3];
auto s = sum(ints);
}
//----
Here, "ints" is an rvalue static array, and slicing it is legit.
So it appears my initial description of the problem is no accurate. There are
times where you can slice an rvalue array.
Not sure where to take this now.
- Do we say "slicing an Rvalue static array is dangerous, and deprecated,
please do it explicitly"?
- Do we find some way to detect *only* the "rvalue static array to dynamic
array assignment" case?
- Give up?
--
More information about the Digitalmars-d-bugs
mailing list