Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -4262,6 +4262,13 @@ public:
lowerbound = 0;
upperbound = 0;
}
else if (VectorExp ve = e1.isVectorExp())
{
// ve is not handled but a proper error message is returned
// this is to prevent https://issues.dlang.org/show_bug.cgi?id=20042
lowerbound = 0;
upperbound = ve.dim;
}
else
assert(0);

Expand Down
29 changes: 29 additions & 0 deletions test/fail_compilation/ice20042.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
DISABLED: freebsd32 linux32 osx32 win32
TEST_OUTPUT:
---
fail_compilation/ice20042.d(18): Error: slice operation `cast(__vector(float[4]))nanF = [1.00000F, 2.00000F, 3.00000F, 4.00000F][0..4]` cannot be evaluated at compile time
fail_compilation/ice20042.d(25): called from here: `Vec4(cast(__vector(float[4]))[nanF, nanF, nanF, nanF]).this([1.00000F, 2.00000F, 3.00000F, 4.00000F])`
---
*/
void write(T...)(T t){}

struct Vec4
{
__vector(float[4]) raw;

this(const(float[4]) value...) inout pure @safe nothrow @nogc
{
__vector(float[4]) raw;
raw[] = value[];
this.raw = raw;
}
}

void main()
{
static immutable Vec4 v = Vec4( 1.0f, 2.0f, 3.0f, 4.0f );

static foreach(d; 0 .. 4)
write(v.raw[d], " ");
}