Skip to content

Commit

Permalink
fix Issue 9537 - auto ref returns a reference its own stack
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jan 11, 2015
1 parent dc6235b commit 8488306
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/fail_compilation/fail9537.d
@@ -0,0 +1,27 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail9537.d(26): Error: foo(tuple(1, 2)) is not an lvalue
---
*/

struct Tuple(T...)
{
T field;
alias field this;
}

Tuple!T tuple(T...)(T args)
{
return Tuple!T(args);
}

auto ref foo(T)(auto ref T t)
{
return t[0]; // t[0] is deduced to non-ref
}

void main()
{
int* p = &foo(tuple(1, 2));
}

0 comments on commit 8488306

Please sign in to comment.