Skip to content

Commit

Permalink
Merge pull request #3521 from 9rnsr/fix12689
Browse files Browse the repository at this point in the history
Issue 12689 - [CTFE] assigning via pointer from 'in' expression doesn't work
  • Loading branch information
WalterBright committed May 3, 2014
2 parents 3f9aba8 + ce9cab4 commit b223603
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/interpret.c
Expand Up @@ -2786,7 +2786,7 @@ class Interpreter : public Visitor
#endif
if (e->ownedByCtfe) // We've already interpreted all the elements
{
result = copyLiteral(e);
result = e;
return;
}
for (size_t i = 0; i < e->keys->dim; i++)
Expand Down
14 changes: 14 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -2719,6 +2719,20 @@ static assert(!bug4065("xx"));
static assert(bug4065("aa"));
static assert(bug4065("bb"));

/**************************************************
12689 - assigning via pointer from 'in' expression
**************************************************/

int g12689()
{
int[int] aa;
aa[1] = 13;
assert(*(1 in aa) == 13);
*(1 in aa) = 42;
return aa[1];
}
static assert(g12689() == 42);

/**************************************************
Pointers in ? :
**************************************************/
Expand Down

0 comments on commit b223603

Please sign in to comment.