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(); } ```
FWIW scope & new will result in an allocation on the stack, though I agree that this should be properly documented.
@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
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