Skip to content

Commit

Permalink
Merge pull request #6268 from WalterBright/fix16381
Browse files Browse the repository at this point in the history
fix Issue 16381 - Wrapping a float4 array leads to segfault
  • Loading branch information
andralex committed Nov 21, 2016
2 parents df96ac9 + 1429da4 commit 2210757
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -4390,6 +4390,16 @@ extern (C++) final class TypeVector : Type
{
printf("TypeVector::dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
}
if (ident == Id.ptr && e.op == TOKcall)
{
/* The trouble with TOKcall is the return ABI for float[4] is different from
* __vector(float[4]), and a type paint won't do.
*/
e = new AddrExp(e.loc, e);
e = e.semantic(sc);
e = e.castTo(sc, basetype.nextOf().pointerTo());
return e;
}
if (ident == Id.array)
{
//e = e->castTo(sc, basetype);
Expand Down
18 changes: 18 additions & 0 deletions test/fail_compilation/test16381.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
REQUIRED_ARGS: -m64
PERMUTE_ARGS:
TEST_OUTPUT:
---
fail_compilation/test16381.d(16): Error: foo() is not an lvalue
---
*/

// https://issues.dlang.org/show_bug.cgi?id=16381

__vector(float[4]) foo();

void bar()
{
float g = foo().ptr[0];
}

0 comments on commit 2210757

Please sign in to comment.