Skip to content

Fix check if nested function can access outer function frame#1888

Merged
kinke merged 1 commit intoldc-developers:masterfrom
kinke:fix1864
Nov 18, 2016
Merged

Fix check if nested function can access outer function frame#1888
kinke merged 1 commit intoldc-developers:masterfrom
kinke:fix1864

Conversation

@kinke
Copy link
Member

@kinke kinke commented Nov 17, 2016

The previous check wouldn't check intermediate aggregates for static-ness, that was one problem. The other was the assertion that the outer function can be reached as long as there are no static functions inbetween, which isn't always the case, as issue #1864 clearly shows, which is resolved by this.

fd = getParentFunc(fd, false);
assert(fd);
while (fd && fd != vdparent) {
fd = getParentFunc(fd);
Copy link
Member Author

@kinke kinke Nov 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd will be null if fd is static (or a function literal) or if there are static aggregates in the parents hierarchy from fd up to the next outer function (if any, otherwise null as well). Note that this was the only place where stopOnStatic was false, apparently only to check for static-ness manually for the error, but unfortunately that false lead to static aggregate parents (and implicitly static function literals) being ignored.

@JohanEngelen
Copy link
Member

The testcase is missing from the PR.

@kinke
Copy link
Member Author

kinke commented Nov 18, 2016

It'd be a dmd-testsuite one (so added later), if it actually makes sense - I think it's really a front-end bug and should work, so I'm rather reluctant to add one.

@JohanEngelen
Copy link
Member

Whereever the bug is, we need a testcase for this.

@kinke
Copy link
Member Author

kinke commented Nov 18, 2016

My point is that I'm reluctant to add an output-matching fail-compilation test for something that looks like it should be working. I.e., a test making sure that something produces an error (instead of crashing), although it looks like valid code.

@JohanEngelen
Copy link
Member

Ah, I misunderstood. So the problem is probably a rejects-valid type of bug?
You seem to have fixed two bugs, none of the two can be tested?

@kinke
Copy link
Member Author

kinke commented Nov 18, 2016

Probably, yes, I'm not sure. I can obviously add a test for the time being, so that we at least get notified when it works (if ever).

The other thing wrt. static aggregate parents/function literals is probably hard/impossible to test, as I guess the front-end rejects the code earlier and we never get into a problematic DtoNestedVariable() call. I think that check is only performed to make sure we can later really access all the frames in LDC's nested context code via later usages of getParentFunc().

@JohanEngelen
Copy link
Member

The changes LGTM.

I prefer a test for the time being, but leave it to you.

The previous check wouldn't check intermediate aggregates for static-ness,
that was one problem. The other was the assertion that the outer function
can be reached as long as there are no static functions inbetween, which
isn't always the case, as issue ldc-developers#1864 clearly shows, which is resolved by
this.
@kinke
Copy link
Member Author

kinke commented Nov 18, 2016

I've added the test.

@kinke kinke merged commit 7ebcae7 into ldc-developers:master Nov 18, 2016
@kinke kinke deleted the fix1864 branch November 18, 2016 20:40
kinke added a commit to kinke/ldc that referenced this pull request Jul 23, 2017
CMake uses incremental linking for MSVC targets by default, with apparent
effect on the alignment of globals. A bunch of unittests have been failing
on Win64 without these fixes since letting CMake link the test runners.

Rainer has fixed the 2 Phobos locations upstream already; the
`core.thread` bug is still unfixed, I submitted PR ldc-developers#1888.
kinke added a commit to kinke/ldc that referenced this pull request Jul 23, 2017
CMake uses incremental linking for MSVC targets by default, with apparent
effect on the alignment of globals. A bunch of unittests have been failing
on Win64 without these fixes since letting CMake link the test runners.

Rainer has fixed the 2 Phobos locations upstream already; the
`core.thread` bug is still unfixed, I submitted PR ldc-developers#1888.
kinke added a commit to kinke/ldc that referenced this pull request Jul 26, 2017
CMake uses incremental linking for MSVC targets by default, with apparent
effect on the alignment of globals. A bunch of unittests have been failing
on Win64 without these fixes since letting CMake link the test runners.

Rainer has fixed the 2 Phobos locations upstream already; the
`core.thread` bug is still unfixed, I submitted PR ldc-developers#1888.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants