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 regression #22909; don't optimize result init if statements can raise which corrupts the compiler #23271

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Feb 1, 2024

fixes #22909
required by #23267

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

@ringabout ringabout changed the title fixes #22909; don't optimize result init if statements can raise fixes regression #22909; don't optimize result init if statements can raise which corrupts the compiler Feb 1, 2024
@ringabout ringabout marked this pull request as draft February 1, 2024 14:40
@ringabout ringabout marked this pull request as ready for review February 1, 2024 14:47
@Araq Araq merged commit 7d97210 into devel Feb 1, 2024
20 of 22 checks passed
@Araq Araq deleted the pr_result_asgn branch February 1, 2024 15:51
Copy link
Contributor

github-actions bot commented Feb 1, 2024

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

Hint: mm: orc; opt: speed; options: -d:release
177842 lines; 7.733s; 768.367MiB peakmem

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)
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.

Compiler segfaults when passing static parameter to non static macro parameter
2 participants