Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dmd-cxx] fix Issue 19898 - ICE: in sizemask at dmd/mtype.d(2563): Assertion failure #9998

Merged
merged 1 commit into from Jun 9, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/intrange.c
Expand Up @@ -278,7 +278,7 @@ IntRange IntRange::fromType(Type *type)

IntRange IntRange::fromType(Type *type, bool isUnsigned)
{
if (!type->isintegral())
if (!type->isintegral() || type->toBasetype()->ty == Tvector)
return widest();

uinteger_t mask = type->sizemask();
Expand Down Expand Up @@ -404,7 +404,7 @@ IntRange& IntRange::castDchar()

IntRange& IntRange::cast(Type *type)
{
if (!type->isintegral())
if (!type->isintegral() || type->toBasetype()->ty == Tvector)
return *this;
else if (!type->isunsigned())
return castSigned(type->sizemask());
Expand All @@ -416,7 +416,7 @@ IntRange& IntRange::cast(Type *type)

IntRange& IntRange::castUnsigned(Type *type)
{
if (!type->isintegral())
if (!type->isintegral() || type->toBasetype()->ty == Tvector)
return castUnsigned(UINT64_MAX);
else if (type->toBasetype()->ty == Tdchar)
return castDchar();
Expand Down
14 changes: 14 additions & 0 deletions test/fail_compilation/fail19898a.d
@@ -0,0 +1,14 @@
/*
PERMUTE_ARGS:
REQUIRED_ARGS: -m64
TEST_OUTPUT:
---
fail_compilation/fail19898a.d(11): Error: incompatible types for `(__key2) < (__limit3)`: both operands are of type `__vector(int[4])`
---
*/
void f (__vector(int[4]) n)
{
foreach (i; 0 .. n)
cast(void)n;
}

21 changes: 21 additions & 0 deletions test/fail_compilation/fail19898b.d
@@ -0,0 +1,21 @@
/*
PERMUTE_ARGS:
REQUIRED_ARGS: -m64
TEST_OUTPUT:
---
fail_compilation/fail19898b.d(18): Error: cannot implicitly convert expression `m` of type `S` to `__vector(int[4])`
fail_compilation/fail19898b.d(18): Error: incompatible types for `(__key2) != (__limit3)`: both operands are of type `__vector(int[4])`
fail_compilation/fail19898b.d(18): Error: cannot cast expression `__key2` of type `__vector(int[4])` to `S`
---
*/
struct S
{
int a;
}

void f (__vector(int[4]) n, S m)
{
foreach (i; m .. n)
cast(void)n;
}