D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18830 - Document Allowance for "new" with "scope" in @nogc Functions
Summary: Document Allowance for "new" with "scope" in @nogc Functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: x86_64 Linux
: P3 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-05 14:26 UTC by Vijay Nayar
Modified: 2023-02-02 12:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vijay Nayar 2018-05-05 14:26:28 UTC
For the description for @nogc functions as found here:
https://dlang.org/spec/function.html#nogc-functions

It is not indicated that "new" declarations may be compatible with "@nogc" functions provided that they are only used for "scope" variables.  The following program compiles on the dlang.org website:

```
class Bob {
	int a;
}

void doThing() @nogc {
	scope auto b = new Bob();
}

void main() {
	doThing();
}
```
Comment 1 Seb 2018-05-06 00:35:49 UTC
FWIW scope & new will result in an allocation on the stack, though I agree that this should be properly documented.
Comment 2 Dlang Bot 2023-02-02 10:01:13 UTC
@RaresCon created dlang/dlang.org pull request #3515 "Fixed issue 18830 - document "new" with "scope" in @nogc Functions" mentioning this issue:

- Fixed issue 18830 - document "new" with "scope" in @nogc Functions

https://github.com/dlang/dlang.org/pull/3515
Comment 3 Dlang Bot 2023-02-02 12:47:20 UTC
dlang/dlang.org pull request #3515 "Fixed issue 18830 - document "new" with "scope" in @nogc Functions" was merged into master:

- 9d04378250a90b506bf1ed22ff35d35edd762589 by RaresCon:
  Fixed issue 18830 - document "new" with "scope" in @nogc Functions

- f5706c8e76ff48c92dd1e5e3ba7bcccb4e114a2f by RaresCon:
  Fix Issue 18830 - document "new" with "scope" in @nogc Functions

https://github.com/dlang/dlang.org/pull/3515