Bug 18830 – Document Allowance for "new" with "scope" in @nogc Functions
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-05-05T14:26:28Z
Last change time
2023-02-02T12:47:20Z
Assigned to
No Owner
Creator
Vijay Nayar
Comments
Comment #0 by madric — 2018-05-05T14:26:28Z
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 by greeenify — 2018-05-06T00:35:49Z
FWIW scope & new will result in an allocation on the stack, though I agree that this should be properly documented.
Comment #2 by dlang-bot — 2023-02-02T10:01:13Z
@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 by dlang-bot — 2023-02-02T12:47:20Z
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