mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
fix Issue 23391 - [Reg 2.098.1] Segmentation fault with static foreach + range + inout
This commit is contained in:
parent
07ece2730b
commit
b953c592c1
2 changed files with 39 additions and 1 deletions
|
@ -1249,7 +1249,14 @@ UnionExp Slice(Type type, Expression e1, Expression lwr, Expression upr)
|
|||
}
|
||||
}
|
||||
|
||||
if (e1.op == EXP.string_ && lwr.op == EXP.int64 && upr.op == EXP.int64)
|
||||
if (!lwr)
|
||||
{
|
||||
if (e1.op == EXP.string_)
|
||||
emplaceExp(&ue, e1);
|
||||
else
|
||||
cantExp(ue);
|
||||
}
|
||||
else if (e1.op == EXP.string_ && lwr.op == EXP.int64 && upr.op == EXP.int64)
|
||||
{
|
||||
StringExp es1 = e1.isStringExp();
|
||||
const uinteger_t ilwr = lwr.toInteger();
|
||||
|
|
31
compiler/test/compilable/issue23391.d
Normal file
31
compiler/test/compilable/issue23391.d
Normal file
|
@ -0,0 +1,31 @@
|
|||
struct MyTuple {
|
||||
string s;
|
||||
}
|
||||
|
||||
inout(string) myfront(inout(string)[] a)
|
||||
{
|
||||
return a[0];
|
||||
}
|
||||
|
||||
MyTuple[] myarray(MyZip r)
|
||||
{
|
||||
MyTuple[] result;
|
||||
foreach (e; r)
|
||||
result ~= e;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct MyZip
|
||||
{
|
||||
bool empty = false;
|
||||
MyTuple front()
|
||||
{
|
||||
return MyTuple([""].myfront);
|
||||
}
|
||||
void popFront()
|
||||
{
|
||||
empty = true;
|
||||
}
|
||||
}
|
||||
|
||||
static foreach(t; MyZip().myarray) {}
|
Loading…
Add table
Add a link
Reference in a new issue