Bug 21744 – [REG 2.092.0] NRVO sometimes not performed when it should be

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-22T00:54:42Z
Last change time
2024-12-13T19:15:19Z
Assigned to
No Owner
Creator
Nathan S.
Moved to GitHub: dmd#19892 →

Comments

Comment #0 by n8sh.secondary — 2021-03-22T00:54:42Z
The following code compiles before v2.092 but fails to compile in v2.092 due to `@disable this(this)`. Digger identifies https://github.com/dlang/dmd/pull/10885 as the PR that broke it. --- // Commenting out `@safe:` will make this compile with no other changes. @safe: struct S(bool isVeryWeird) { @disable this(this); static if (isVeryWeird) { uint notEnum = 2; // Changing `maybeEnum` to a non-template function will make // this compile with no other changes. @property uint maybeEnum()() { // Replacing `return notEnum` with `return 0` will make // this compile with no other changes. return notEnum; } } else enum uint maybeEnum = 0; // Removing the following `static if` block will make this compile // with no other changes. static if (__traits(compiles, { enum e = maybeEnum; })) { // Empty } @property S spawnAnother()() const { S result; return result; } } void main() { auto a = S!false.init; auto b = a.spawnAnother; // Succeeds. auto c = S!true.init; auto d = c.spawnAnother; // Compile error. } ---
Comment #1 by robert.schadek — 2024-12-13T19:15:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19892 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB