fix Issue 8832 - Segfault when accessing range returned by function that... #1575

Merged
merged 1 commit into from Jan 29, 2013

Conversation

Projects
None yet
2 participants
@WalterBright
Owner

WalterBright commented Jan 29, 2013

... has delegate referencing local variables

This extends Don's earlier fix D-Programming-Language#1554
to cover this case as well.

Fix http://d.puremagic.com/issues/show_bug.cgi?id=8832

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Jan 29, 2013

I am very glad to see yet another lambda bug to be fixed. Thank you. So far, you and Don have fixed 7 Bugzilla issues related to the problem (8774, 8514, 8854, 5064, 1350, recently 1841 and this one). The only lambda bug which is still is not fixed by recent pulls is 7978. I am not aware of any other lambda bugs.

ghost commented Jan 29, 2013

I am very glad to see yet another lambda bug to be fixed. Thank you. So far, you and Don have fixed 7 Bugzilla issues related to the problem (8774, 8514, 8854, 5064, 1350, recently 1841 and this one). The only lambda bug which is still is not fixed by recent pulls is 7978. I am not aware of any other lambda bugs.

@don-clugston-sociomantic

This comment has been minimized.

Show comment Hide comment
@don-clugston-sociomantic

don-clugston-sociomantic Jan 29, 2013

Contributor

Better test case (no use of Phobos):

int Bug8832(alias X)()
{
    return X();
}

int delegate() foo8832()
{
  int stack;
  int heap = 3;

  int nested_func()
  {
    ++heap;
    return heap;
  }
  return delegate int() { return Bug8832!(nested_func); };
}

void main()
{
  auto z = foo8832();
  auto p = foo8832();
  assert(z() == 4);
  p();
  assert(z() == 5);
}
Contributor

don-clugston-sociomantic commented Jan 29, 2013

Better test case (no use of Phobos):

int Bug8832(alias X)()
{
    return X();
}

int delegate() foo8832()
{
  int stack;
  int heap = 3;

  int nested_func()
  {
    ++heap;
    return heap;
  }
  return delegate int() { return Bug8832!(nested_func); };
}

void main()
{
  auto z = foo8832();
  auto p = foo8832();
  assert(z() == 4);
  p();
  assert(z() == 5);
}
@WalterBright

This comment has been minimized.

Show comment Hide comment
@WalterBright

WalterBright Jan 29, 2013

Owner

Replaced the test case with Don's.

Owner

WalterBright commented Jan 29, 2013

Replaced the test case with Don's.

WalterBright added a commit that referenced this pull request Jan 29, 2013

Merge pull request #1575 from WalterBright/b43
fix Issue 8832 - Segfault when accessing range returned by function that...

@WalterBright WalterBright merged commit fe75833 into dlang:master Jan 29, 2013

1 check failed

default Pass: 7, Fail: 1, Pending: 2
Details

@WalterBright WalterBright deleted the WalterBright:b43 branch Jan 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment