Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #22672; Destructor not called for result when exception is thrown #23267

Merged
merged 14 commits into from
Jun 6, 2024

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Jan 30, 2024

fixes #22672

Araq pushed a commit that referenced this pull request Feb 1, 2024
… raise which corrupts the compiler (#23271)

fixes #22909
required by #23267

```nim
proc foo: string =
  assert false
  result = ""
```

In the function `foo`, `assert false` raises an exception, which can
cause `result` to be uninitialized if the default result initialization
is optimized out
compiler/cgen.nim Outdated Show resolved Hide resolved
@ringabout ringabout changed the title fixes #22672; Destructor not called for result when exception is thrown fixes #22672; fixes #22852; Destructor not called for result when exception is thrown Feb 2, 2024
@ringabout ringabout changed the title fixes #22672; fixes #22852; Destructor not called for result when exception is thrown fixes #22672; Destructor not called for result when exception is thrown Feb 2, 2024
@ringabout ringabout marked this pull request as ready for review February 2, 2024 14:52
@arnetheduck
Copy link
Contributor

see also #14126 (whose fix was rolled back afair)

@ringabout
Copy link
Member Author

see also #14126 (whose fix was rolled back afair)

It has worked with ORC in the devel branch

narimiran pushed a commit that referenced this pull request Apr 22, 2024
… raise which corrupts the compiler (#23271)

fixes #22909
required by #23267

```nim
proc foo: string =
  assert false
  result = ""
```

In the function `foo`, `assert false` raises an exception, which can
cause `result` to be uninitialized if the default result initialization
is optimized out

(cherry picked from commit 7d97210)
@Araq Araq merged commit 8f5ae28 into devel Jun 6, 2024
22 checks passed
@Araq Araq deleted the pr_except_orc branch June 6, 2024 09:51
Copy link
Contributor

github-actions bot commented Jun 6, 2024

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 8f5ae28

Hint: mm: orc; opt: speed; options: -d:release
178718 lines; 8.298s; 664.633MiB peakmem

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.

Destructor not called for result when exception is thrown
3 participants